0

After researching SO and Google, I think that due to my limited english, I cannot find an answer to my question.

In an Activity, I simply want to open the "message option dialog" when clicking a button. It should recognize wheter the user has WhatsApp or not and put that option in the dialog (or not). Optionally for all possible message applications like facebook, hangouts. Is there a global way to achieve this?

I am sorry to not provide some code, but I think this is more a general question.

Valentino Ru
  • 4,964
  • 12
  • 43
  • 78
  • Is it that: http://stackoverflow.com/questions/4431386/android-share-intent-chooser ? – zapl Dec 05 '13 at 17:14

1 Answers1

1

Android has this thing called Intents.

It basically means that applications can register to handle certain intents, and your application can ask Android to provide a list of applications that can do what you are asking.

To send a message, you need to create a intent that looks like:

//create our intent with a action of ACTION_SEND
Intent sendIntent = new Intent(Intent.ACTION_SEND);
//we want to send a simple 'text' message
sendIntent.setType("text/plain");
//this is the text we are sending
sendIntent.putExtra(Intent.EXTRA_TEXT, messageToSend);
//ask android to show apps that can handle this intent
startActivity(Intent.createChooser(sendIntent, "Send message"));

Hope that helps!

athor
  • 6,848
  • 2
  • 34
  • 37