当我尝试将图片网址附加到推文时,我正在获取 Image Could Not Be Loaded
。我改变了类型,但仍然没有工作。
我的意图代码:
String imageUrl="http://www.cyclesoon.com/admin/assets/img/rideimages/1499161893615.jpg";
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.putExtra(Intent.EXTRA_TEXT, "Join ride");
tweetIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageUrl));
tweetIntent.setType("image/png");
PackageManager packManager = context.getPackageManager();
List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY);
boolean resolved = false;
for (ResolveInfo resolveInfo : resolvedInfoList) {
if (resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")) {
tweetIntent.setClassName(resolveInfo.activityInfo.packageName,resolveInfo.activityInfo.name);
resolved = true;
break;
}
}
if (resolved) {
startActivity(tweetIntent);
} else {
Intent i = new Intent();
i.putExtra(Intent.EXTRA_TEXT, "");
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://twitter.com/intent/tweet?text=" + urlEncode("")));
startActivity(i);
}
任何解决方案都赞赏。
答案 0 :(得分:0)
如果看到documentation,则会出现一行说明图像Uri应该是文件Uri(即file:// absolute_path scheme)到本地文件。所以是的,Image应该在你的设备上。 - Mohammed Atif