Add “Like Us on Facebook” button to your Android App

It’s really a good idea to include the link to your Facebook page in the Android app. It will help you to keep in touch with the users of your app.

Below is the code you should put in the click event of the “Like Us on Facebook” button.

String fbPageId = "149483785425721";
String fbPageUrl = "";

try {
  getPackageManager().getPackageInfo("com.facebook.katana", 0);
  Intent fb = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + fbPageId));
} catch (Exception e) {
  Intent fb = new Intent(Intent.ACTION_VIEW,  Uri.parse(fbPageUrl));

You just need to replace the fbPageId and fbPageUrl in above code. You can find the page id of your Facebook page in Your Page -> Settings -> Page Info section.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s