5

I'm using an Intent with ACTION_SEND and I need to share different texts. I need to send a text for Gmail and I need to send other text for twitter. depends on the application. Can I get the application selected by the user before the application sends the text shared?

Alex
  • 6,957
  • 12
  • 42
  • 48
  • possible duplicate of [Android Intent for Twitter application](http://stackoverflow.com/questions/2077008/android-intent-for-twitter-application) – Matthew Mar 15 '11 at 15:25
  • check your answer here [Twidroid’s ACTION_SEND intent][1] [1]: http://stackoverflow.com/questions/2077008/android-intent-for-twitter-application/4715465#4715465 – Muhammad Usman Ghani Mar 05 '14 at 10:10
  • See http://stackoverflow.com/a/18068122/82788 – matiash Jan 29 '15 at 20:18

3 Answers3

4

Yes, you can get the application selected by the user before the application sends the text shared. For this you have to make a workaround, i.e.:

You have to get list of which applications are supported for this intent by:

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
List activities = getPackageManager().queryIntentActivities(sharingIntent,0);

By getting the list. we can built a alert dialog and then make listener for different applications.

3

In general you can't be sure which application will receive your ACTION_SEND intent.

This answer explains why you probably shouldn't do customization based on predicting which application the user will end up in.

This answer explains a workaround for TwiDroyd, which you probably shouldn't use but may help you in the short term.

Community
  • 1
  • 1
Matthew
  • 44,826
  • 10
  • 98
  • 87
0

I don't have idea of getting the user selected application to send something.

But you can choose programatically the apk to open your intent using an IntentResolver.

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167