Share link in facebook android example
Here,i have written the simple code to share link in facebook android example using the facebook application.
1)Create the link what you are going to share,
String urlToShare = "http://androidtoppers.com"; |
2)Create the intent to share the link,
Intent intent = newIntent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, urlToShare); |
3)Get all the available application to share the data using the ResoveInfo,
List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0); |
4)Filter the facebook application from the group of application available to share the data,
for (ResolveInfo info : matches) {
if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook")) {
intent.setPackage(info.activityInfo.packageName);
facebookAppFound = true;
break;
} } |
5)startActivity to share the link with the facebook,
startActivity(intent); |
Screenshot:
2 comments:
if i want to share a link on a other social network, how will i do ?
total bullshit .................
Post a Comment