How to hide the share action (which use most) icon near the share action provider?

前端 未结 3 1654
无人及你
无人及你 2020-11-30 08:21

See the picture. How can i hide the icon \"P\" which means share to Pinterest?

\"enter

3条回答
  •  执笔经年
    2020-11-30 08:42

    Based off Sean's answer I created the necessary classes, you can copy them into your project (https://gist.github.com/saulpower/10557956). This not only adds the ability to turn off history, but also to filter the apps you would like to share with (if you know the package name).

    private final String[] INTENT_FILTER = new String[] {
            "com.twitter.android",
            "com.facebook.katana"
    };
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.journal_entry_menu, menu);
    
        // Set up ShareActionProvider's default share intent
        MenuItem shareItem = menu.findItem(R.id.action_share);
    
        if (shareItem instanceof SupportMenuItem) {
            mShareActionProvider = new ShareActionProvider(this);
            mShareActionProvider.setShareIntent(ShareUtils.share(mJournalEntry));
            mShareActionProvider.setIntentFilter(Arrays.asList(INTENT_FILTER));
            mShareActionProvider.setShowHistory(false);
            ((SupportMenuItem) shareItem).setSupportActionProvider(mShareActionProvider);
        }
    
        return super.onCreateOptionsMenu(menu);
    }
    

提交回复
热议问题