Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Facebook Share Intent
public static void shareURL(Context context, String url) {
try {
Intent intent1 = new Intent();
intent1.setClassName("com.facebook.katana", "com.facebook.composer.shareintent.ImplicitShareIntentHandler");
intent1.setAction("android.intent.action.SEND");
intent1.setType("text/plain");
intent1.putExtra("android.intent.extra.TEXT", url);
context.startActivity(intent1);
} catch (Throwable e) {
// If native FB app is not installed, try share through SEND (browser or 3rd party apps)
String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + url;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
context.startActivity(intent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.