Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ACTION_SEND different texts for each application

Tags:

android

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?

like image 337
Alex Avatar asked Mar 15 '11 15:03

Alex


2 Answers

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.

like image 180
Prince Sachdeva Avatar answered Nov 06 '22 07:11

Prince Sachdeva


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.

like image 32
Matthew Willis Avatar answered Nov 06 '22 05:11

Matthew Willis