Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShareActionProvider appearance

I have android.support.v7.widget.ShareActionProvider menu in my ActionBar.

When I click "Share", the app list appears as a popup menu.

When I click "Share" in Google Play Newsstand, the app list appears as a bottom sheet that can be pulled up.

Can we configure ShareActionProvider from appcompat-v7 to display bottom sheet instead of popup menu? Are there any alternative ShareActionProvider with bottom sheet around?

I found a lib https://github.com/soarcn/BottomSheet. It gives an idea how to re-implement the ShareActionProvider with bottom sheet. Unfortunately it looks like the lib is missing 'swipe up to pull up' at this moment. And more over, I still have to resolve intents, handle screen rotations and support all the Android versions... Shouldn't this be included in appcompat-v7?

like image 736
Dima Kornilov Avatar asked Feb 17 '15 20:02

Dima Kornilov


1 Answers

The solution is to use Intent.createChooser instead of ShareActionProvider. It gives exactly the same experience as sharing an article from Google Newsstand on Android 5.0.

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, ...);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.item_share)));
like image 184
Dima Kornilov Avatar answered Oct 13 '22 20:10

Dima Kornilov