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 action bar. Is there anyway to turn this off?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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).Start the share activity by yourself:
Then the ShareActionProvider will not add the chosen activity to the share history.
I created my own version of the ShareActionProvider (and supporting 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).
add the code like this:
For me, the best solution for avoid the history icon is don't use ShareActionProvider, instead of it, create it as any other action:
at the menu/activity_actions.xml put a item with the ic_action_share icon...
Inflate the menu normally...
Create a method with an ACTION_SEND intent
And finally call to this method from onOptionsItemSelected
more info ->Sending Simple Data to Other Apps
Although It's been 2 years ago today but I'd like to share my experience as I made a custom ShareActionProvider class and add this line
chooserView.getDataModel().setHistoryMaxSize(0);
inside onCreateActionView() which did all the magic for me ! .. I tested it on Lollipop device and on API 16 emulator device and it works perfectly. here is my custom class :