Nul*_*ion 22 twitter android android-intent
我想让用户可以通过Twitter和Facebook分享图像和文本.
实际上我的代码可以启动Android的共享意图,如果用户选择Facebook,一切正常,图像被附加,文本显示在新状态的主体上.
但Twitter出了问题,如果我只把一张图片全部正常工作,图片会被推特检测到并自动上传到twipic,然后twitter在推文上发布图片的链接.但是,如果我放置图像和文本,那么,twitter不会检测图像,它只会将文本放在推文上,图像会被忽略.怎么了?
这是我的代码:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
Run Code Online (Sandbox Code Playgroud)
Pas*_*lis 22
您仍然可以尝试使用ACTION_SEND,而不使用ACTION_SEND_MULTIPLE.
ACTION_SEND_MULTIPLE 当我试图创建新的意图分享到Gmail,G +等时,导致一个强制关闭.
这对我来说很完美:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
Uri uri = Uri.parse("file:///sdcard/image.jpg");
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
return shareIntent;
Run Code Online (Sandbox Code Playgroud)
Nik*_*ski 14
同时为文本指定MIME类型."text/plain"是文本数据MIME的类型.尝试使用"*/*"MIME,因此您可以发送任何通用数据类型.
还尝试更改ACTION_SEND为ACTION_SEND_MULTIPLE专门用于提供多个数据的内容.
有关ACTION_SEND_MULTPLE和处理MIME类型的更多信息:
http://developer.android.com/reference/android/content/Intent.html
| 归档时间: |
|
| 查看次数: |
26997 次 |
| 最近记录: |