【发布时间】:2015-01-09 10:48:31
【问题描述】:
您好朋友,我在 facebook 墙上分享功能时遇到问题。我正在共享文本和图像,这是我的应用程序的捕获屏幕。但我无法使用以下代码共享文本。请帮我解决这个问题。
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "your sharing text");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri); // Share
// the
// image
// on
// Facebook
PackageManager pm = mActivity.getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{
if ((app.activityInfo.name).contains(sharingapp))
{
c++;
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setComponent(name);
startActivity(shareIntent);
break;
}
}
【问题讨论】:
-
你为什么不使用FaceBookShareDialog?检查 Facebook SDK 或在这里github.com/b099l3/FacebookImageShareIntent
-
使用 Intent 没问题,但是 Facebook 不允许您设置消息,因为这违反了平台策略。用户必须自己输入消息。
标签: android facebook android-facebook android-sharing