Last active
December 28, 2015 21:29
-
-
Save sir4ju1/7565437 to your computer and use it in GitHub Desktop.
Facebook Like button for android
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
public static Intent getOpenFacebookIntent(Context context) { | |
try { | |
context.getPackageManager() | |
.getPackageInfo("com.facebook.katana", 0); //Checks if FB is even installed. | |
return new Intent(Intent.ACTION_VIEW, | |
Uri.parse("fb://profile/254175194653125")); //Trys to make intent with FB's URI | |
} catch (Exception e) { | |
return new Intent(Intent.ACTION_VIEW, | |
Uri.parse("https://www.facebook.com/sentiapps")); //catches and opens a url to the desired page | |
} | |
} | |
//USAGE | |
Intent facebookIntent = getOpenFacebookIntent(this); | |
startActivity(facebookIntent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment