How do you turn off share history when using ShareActionProvider?

后端 未结 8 642
遇见更好的自我
遇见更好的自我 2020-12-02 23:31

The new ShareActionProvider available in Android 4.0 (or in earlier versions if you\'re using ActionBarSherlock) has a feature where the last used item is displayed in the a

相关标签:
8条回答
  • 2020-12-02 23:57
        getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);
    
        // Set file with share history to the provider and set the share intent.
        MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
        ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
        ***actionProvider.setShareHistoryFileName(null);
        OnShareTargetSelectedListener listener = new OnShareTargetSelectedListener() {
            public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
                startActivity(intent);
                return true;
            }
        };
        actionProvider.setOnShareTargetSelectedListener(listener);***
    
    0 讨论(0)
  • 2020-12-03 00:03

    There is no API to do this. However, the class is really simple and you could very easily create your own version of ShareActionProvider that did not keep a history. You would just have to determine the sort order of the possible targets using some other means of ordering (e.g., alphabetically).

    0 讨论(0)
提交回复
热议问题