Android : i want to share my application on facebook but this code is not working

on Friday, September 12, 2014


trying to share my application on facebook, i have given a button inside my app,and have given this below code onClick event of the button but it doesn't do anything,please help



Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, MYAPP_LINK);

PackageManager pm = Activity_Main.this.getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{
if ((app.activityInfo.name).contains("facebook") || (app.activityInfo.name).contains("Facebook"))
{
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
Main_Activity.this.startActivity(shareIntent);
}
}

0 comments:

Post a Comment