Appearance of ShareActionProvider

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

When I click "Share", the list of applications appears as a pop-up menu.

When I click "Share" in Google Play Newsstand, the list of applications appears as the bottom sheet that can be pulled out.

Is it possible to configure ShareActionProvider from appcompat-v7 to display the bottom sheet instead of a popup menu? Is there an alternative to ShareActionProvider with bottom sheet around?

I found lib https://github.com/soarcn/BottomSheet . It gives an idea of ​​how to reimplement ShareActionProvider with the bottom sheet. Unfortunately, it seems that at the moment lib is not enough to pull up. And yet, I still have to decide on intentions, handle screen rotations and support all versions of Android ... Should this not be included in appcompat-v7 ?

+5
source share
1 answer

The solution is to use Intent.createChooser instead of ShareActionProvider . This gives the same experience as article sharing 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))); 
+6
source

Source: https://habr.com/ru/post/1213565/


All Articles