如果我只发送文本,Share Intent选择器不会将Facebook / Twitter作为选项 .
只有Gmail,Skype和Evernote可供选择 .
这是我的代码
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("plain/text");
shareIntent.putExtra(Intent.EXTRA_TEXT, text)
startActivity(Intent.createChooser(shareIntent, "Share using"));
我尝试了不同的setType()组合,包括“text / *”,“text / html”,并在putExtra中传递HTML文本,如下所示:
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<p>This is the text that will be shared.</p>"));
当我使用“text / plain”时,Facebook会出现一个选项,但选择它时文本不会加载 . 但该文本确实加载了Twitter,电子邮件,短信 .
还有其他人遇到过这个问题吗?
当我分享图像时,没有问题,Facebook和其他社交媒体应用程序在列表中可用 .
4 回答
这取决于每个应用程序定义的intent过滤器 .
例如,如果我添加intent-filter
android.intent.action.send
如果我从图库中选择单个图像,我的应用程序将出现在列表中 . 但是,如果我选择多个,我的应用程序将不会显示,因为我没有为
android.intent.action.send_multiple
添加intent-filer所以它取决于facebook过滤的意图 . 您需要查看发行说明或帮助或开发人员页面 .
根据文档,它也应该是“text / plain”而不是“plain / text” .
Facebook问题是facebook权限的限制 . 使用facebook API
Share via Twitter :
//用于查找Twitter包名---- >>
Share via Facebook
Share via Gmail