我使用以下代码在twitter墙上分享图片和文字。请帮助我为什么以下代码在我的应用程序中不起作用?启动器活动打开但它只显示文本而不显示图像。并且只分享文本而不是图像和文本。
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
final PackageManager pm = mainActivity.getPackageManager();
@SuppressWarnings("rawtypes")
final List activityList = pm.queryIntentActivities(share, 0);
int len = activityList.size();
for (int i = 0; i < len; i++)
{
final ResolveInfo app = (ResolveInfo) activityList.get(i);
Log.print("Packages", app.activityInfo.name);
if (app.activityInfo.packageName.startsWith("com.twitter.android"))
{
Log.print(":::: Twitter Share Name Activity ::: " + (app.activityInfo.name).toString());
try
{
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
share.addCategory(Intent.CATEGORY_LAUNCHER);
share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.setComponent(name);
share.putExtra(Intent.EXTRA_TEXT, Pref.getValue(mainActivity, Labels.TITLE, ""));
share.putExtra(Intent.EXTRA_STREAM, new URI(new URL(imgUrl).toString()));
startActivity(share);
}
catch (Exception e)
{
e.printStackTrace();
Log.error(":::: Twitter image path Exception::::", e.toString());
}
break;
}
}