Open a Facebook fan page from Android application

I’d like to share how to invoke FB fanpage from your Android application programmatically. Before that please get your FB fanpage ID. TO find your FB fanpage ID , LOGIN to your fanpage. Find the Edit Page button and choose any option from the Admin menu. The fanpage ID is located in the URL after the keyword ID. Select and Copy the number.


***Or you could find the page ID at the Edit Page –> Update Page Info, in the Page Info window, look at the bottom (last detail).

This is the code to invoke the FB fanpage on the mobile user’s smartphone from your app. Provide the FB app is installed.

Intent ifb=new Intent (Intent.ACTION_VIEW);
String uri="fb://page/613598055326974"; //your FB fanpage ID is here

Copy and Paste the codes above in your onClick button, or anywhere necessary.

If you consider maybe the phone doesn’t has Facebook app installed, may be you’d like to redirect to a browser instead. Then below is the code;

try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/129569063811850"));
} catch(Exception e) {// or else open in browser instead
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("")));

No comments:

Post a Comment

Popular Posts