Show share menu like other apps on my android phone

1.2k views Asked by At

I have added share action on my app's actionbar and followed these steps:

http://www.codewithasp.net/2016/11/share-action-provider-android-application-actionbar-appcompat-v7.html

This is showing a nice simple looking share menu on my actionbar. But problem is that all other application on my phone have different share menu and all of them are similar.

Here is how my share menu look:

enter image description here

Here is how other apps showing share menu on my device

enter image description here

2

There are 2 answers

3
Nikhil Gaur On BEST ANSWER

There was one more thing to add in SadClown's answer and I got what I wanted. Actually while calling startActivity instead of just pass your share intent we need to call intent chooser

getContext().startActivity(Intent.createChooser(sendIntent, "Share"));

It is explained here in detail

4
SadClown On

Instead of creating a drop-down menu with share options, you should just call share intent once you've clicked on share button or menu option. That way the list of possible apps would be shown as on the example you've pasted.

Here is an example of how could you do it.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, content);
sendIntent.setType("text/plain");
getContext().startActivity(sendIntent);