我正在尝试通过ActionBarSherlock使用共享操作提供程序时共享纯文本,只有四个选项可供共享,没有“查看全部…”选项。
为什么?
这就是它的样子:
这就是我想要的样子:
最佳答案
好吧,不管actionBarSherlock第一个测试是为了看看你是否正确地创建了你的意图,abs使用的代码和generic chooser使用的代码是一样的,所以当你执行这段代码时,看看你正在寻找的应用是否会出现。
Intent I= new Intent(Intent.ACTION_SEND);
I.setType("text/plain");
I.putExtra(android.content.Intent.EXTRA_TEXT, "My Test Text");
startActivity(Intent.createChooser(I,"Share using ..."));
所有处理纯文本的应用程序都将显示,如果Facebook或您期望的其他应用程序不存在,则这些应用程序不支持您注册的类型(纯文本/文本)的“发送意图”操作。(Facebook有,但一分钟后会有更多)
abs有一个使用share action provider的示例,但它尝试发送照片,而不是文本消息(状态更新),您应该使用的设置如下
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate your menu.
getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);
// Set file with share history to the provider and set the share intent.
MenuItem item = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
ShareActionProvider provider = (ShareActionProvider) item.getActionProvider();
provider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
// Note that you can set/change the intent any time,
// say when the user has selected an image.
provider.setShareIntent(createShareIntent());
return true
}
下面是用于匹配应用程序并从示例中列出它们的意图
private Intent createShareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/plain");
Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TITLE, "This is an android icon");
return shareIntent;
}
但你希望它是
private Intent createShareIntent() {
Intent I= new Intent(Intent.ACTION_SEND);
I.setType("text/plain");
I.putExtra(android.content.Intent.EXTRA_SUBJECT, "TEST - Disregard");
I.putExtra(android.content.Intent.EXTRA_TEXT, Uri.parse("http://noplace.com"));
}
这应该会给你同样的列表在abs在它做的小测试存根我显示与以上选择器。
现在是坏消息。facebook应用程序并不能真正工作,它会弹出用户更新页面,但不会填充文本。这是一次又一次的断线,但我昨晚试过了,结果失败了。这是一个被报道和接受的Facebook应用程序错误。你可以张贴照片,虽然标题不能设置请看How many times will Facebook break/fix this?