Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android share intent chooser

I am using something like this to share some text using available applications on the user's phone.

public void share(String subject,String text) {
     final Intent intent = new Intent(Intent.ACTION_SEND);

     intent.setType("text/plain");
     intent.putExtra(Intent.EXTRA_SUBJECT, subject);
     intent.putExtra(Intent.EXTRA_TEXT, text);

     startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

My main problem is that I would like to have a different text if the user chooses Twitter instead of email for example (short version with short URLs VS full text with attached images).

How can ont find out which application the user has decided to use?

like image 671
Vincent Mimoun-Prat Avatar asked Dec 13 '10 17:12

Vincent Mimoun-Prat


People also ask

What is Chooser in intent?

You can specify chooser title. Will always show chooser dialog even when a default app is selected. If no app is available to handle the intent, if will show No application can perform this action message (instead of ActivityNotFoundException exception).

How do I send intent to another app?

Sending text content putExtra(Intent. EXTRA_TEXT, "This is my text to send.") Intent sendIntent = new Intent();


1 Answers

Once you hand the text off to the system with createChooser its out of your hands, no way to change the text after that.

like image 83
Nathan Schwermann Avatar answered Oct 02 '22 15:10

Nathan Schwermann