java - correct way to call facebook page in android? -


i'm trying open facebook page using facebook app if user has facebook app installed, or use browser instead if not. tried following code:

    public static string facebook_url = "https://www.facebook.com/samsung";     public static string facebook_page_id = "samsung";      //method right url use in intent     public string getfacebookpageurl(context context) {         packagemanager packagemanager = context.getpackagemanager();         try {             int versioncode = packagemanager.getpackageinfo("com.facebook.katana", 0).versioncode;             if (versioncode >= 3002850) { //newer versions of fb app                 return "fb://facewebmodal/f?href=" + facebook_url;              } else { //older versions of fb app                 return "fb://page/" + facebook_page_id;             }         } catch (packagemanager.namenotfoundexception e) {             return facebook_url; //normal web url         }     } 

it kind of works. if facebook app not installed, opens page in browser correctly. if facebook app installed, goes feed of facebook page's activity, doens't display facebook page "like/share" buttons , logo.

i tried getting rid of

return "fb://facewebmodal/f?href=" + facebook_url; 

and replacing just

return "fb://page/" + facebook_page_id; 

which heard works on versions of app, not new version, no dice. when using method on recent version of facebook app, not load facebook page, logged in user's home page.

any ideas? i've scoured stackoverflow found above methods. i'm guessing facebook changed in app.

figured out. page_id using page id shown in browser, incorrect. used numeric page id , worked.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -