Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bottom Share Sheet in Android

When sharing data in an Android application I have seen multiple applications use a bottom sheet (Google I/O 2015 for ex.) to indicate apps to perform an action rather than the standard dialog which includes apps to handle your intent.

For example:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TITLE, "Some title..");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Some text");
startActivity(Intent.createChooser(shareIntent, "Share via.."));

does not do the trick since the OS version picks the display of the chooser.

Any way to change this code to get the Share Bottom sheet per the material design https://www.google.com/design/spec/components/bottom-sheets.html#bottom-sheets-contententer image description here

Does anyone know of third party libraries to do just this on older API versions?

I have found https://github.com/soarcn/BottomSheet

but this only lets me create a menu from the bottom sheet. I guess in reality, i can lookup all the apps that can perform the action I am trying to do and manually add Menu Items on top of this library, but i was hoping for something a little simpler since it is not a deal breaking feature.

like image 502
kandroidj Avatar asked Jul 09 '15 23:07

kandroidj


2 Answers

Here is that same exact bottom sheet on a Nexus 5 running Android 6.0.

This may be different on older or modified versions of Android. (i.e. Samsung Devices etc)


Code

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Check out this dope website! - https://mikemiller.design/"); // Simple text and URL to share
sendIntent.setType("text/plain");
this.startActivity(sendIntent);

Result

enter image description here

like image 52
Michael Avatar answered Sep 25 '22 20:09

Michael


Our BottomSheet implementation has a commons component you can use that lets you specify an intent/filter/etc for the sheet and it will behave fairly similarly to the system version on Lollipop

https://github.com/flipboard/bottomsheet

like image 34
Zac Sweers Avatar answered Sep 22 '22 20:09

Zac Sweers