对于带有ActionBarSherlock的ShareActionProvider,只有四个选项

Gre*_*ion 7 android actionbarsherlock android-actionbar shareactionprovider

我正在尝试通过ActionBarSherlock使用共享操作提供程序时共享纯文本,并且只有四个选项可以共享它,并且没有"查看全部..."选项.

这是为什么?

这就是它的样子:

这就是我想要的样子:

Idi*_*tic 8

好的,所以不管ActionBarSherlock首先测试你是否正确创建你的意图,ABS使用与通用选择器相同的代码,这样看看你执行此代码时是否显示你正在寻找的应用程序.

    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 ..."));
Run Code Online (Sandbox Code Playgroud)

处理纯文本的所有应用程序都将显示,如果是facebook,或者您不期望的任何内容,则那些应用程序不支持您已注册类型的ACTION_SEND意图(纯文本/文本).(Facebook确实如此,但在一分钟内更多关于这一点)

ABS有一个使用共享操作提供程序的示例,但它尝试发送照片,而不是文本消息(状态更新)您应该使用的设置是这样的

@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
}
Run Code Online (Sandbox Code Playgroud)

这里的意图将用于匹配应用程序并从示例中列出它们

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;
    }
Run Code Online (Sandbox Code Playgroud)

但你想要它

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"));
    }
Run Code Online (Sandbox Code Playgroud)

这应该给你在ABS中的相同列表,它在我用上面的选择器显示的小测试存根中.

现在是坏消息.Facebook应用程序并不真正起作用,它会调出用户更新页面,但不会填写文本.这是一个又一次,再次破损,但我昨晚尝试了它,它失败了.这是facebook应用程序报告并接受的错误.你可以张贴照片,虽然标题不能设置,请看Facebook破解/修复这个多少次?