1

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

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
Nikhil Gaur
  • 1,280
  • 3
  • 19
  • 40

2 Answers2

4

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);
SadClown
  • 648
  • 8
  • 16
  • This is showing a third layout but this is not what I want. I want to use same share feature which all other apps are showing. May be this will vary by manufacturer but atleast it will be similar to all other apps on that device. – Nikhil Gaur Nov 10 '16 at 12:55
  • 1
    This is a standard way of doing the share action. If you could post the list of apps that are doing it the way you are talking about, maybe I can figure it out, but still you won't be wrong at all if you do the share action the way I showed you. – SadClown Nov 10 '16 at 15:10
  • you are right. actually other apps that I tried were sharing image also along with text that is why different view was available. So when I added image in my share intent it started showing same share view like other apps. Anyways I don't need image so without image is fine. Thanks – Nikhil Gaur Nov 10 '16 at 17:38
  • You may accept my answer if you found it helpful for your problem :) – SadClown Nov 15 '16 at 13:59
0

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

Nikhil Gaur
  • 1,280
  • 3
  • 19
  • 40
  • 2
    One of the very early comments (guy's name is Selvin) on your question told you that it looks like an IntentChooser. You should read such comments and answer to them. It appears that Selvin is the guy who provided you solution, marking your own answer as the correct one is unfair - you have ignored the guy who gave you the right answer, and you are boosting your own score. – SadClown Dec 14 '16 at 10:48
  • Yes I checked that comment but that time I was not able to understand how to use IntentChooser. After using your code I found myself so close to what I want. Then after searching based on that I got this solution of intent chooser (by that time I even forgot about that comment). And I can not select his comment as answer because that is a comment. – Nikhil Gaur Dec 15 '16 at 10:00
  • Everything is okay, just don't select your own answer, it is not right thing to do, it's like cheating :) Now, if someone sounds like close to your answer (like IntentChooser comment), just ask for clarification, everyone here is willing to clarify their comment. – SadClown Dec 15 '16 at 16:35