Created
May 7, 2015 11:41
-
-
Save captswag/d5b7c0f4246eace41c40 to your computer and use it in GitHub Desktop.
Android, java code for opening facebook profile of a user in the facebook application, if the user has it installed, or open the profile in the web browser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Go to https://graph.facebook.com/<user_name_here> | |
* Copy your id | |
* This will open up facebook app if the user has it installed | |
* Otherwise it will open facebook in the browser | |
*/ | |
public Intent getOpenFacebookIntent(Context context) { | |
try { | |
context.getPackageManager().getPackageInfo("com.facebook.katana", 0); | |
return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/<id_here>")); | |
} | |
catch (Exception e) { | |
return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name>")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment