2

I am developing a new App for android. I basically want to send a WhatsApp message to a list of contacts or numbers in my phone through my App. The important thing here, I would like to do this without using the chooser. In other words, my app will retrieve all my contacts, then it will make some filtering before sending a message to the list without having the user to manually use the Chooser.

And can I do this without Rooting my device? Any help is really appreciated.

Soft Dev
  • 33
  • 2
  • 4
  • check my answer http://stackoverflow.com/questions/24774595/android-how-to-send-message-programatically-by-using-whats-app-we-chat – Subhalaxmi Jun 24 '15 at 09:06

1 Answers1

1

For Share through any application...

public void sendAppMsg(View view) {

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    String text = " message you want to share..";
    // change with required application package

    intent.setPackage("PACKAGE NAME OF THE APPLICATION");
    if (intent != null) {
        intent.putExtra(Intent.EXTRA_TEXT, text);//
        startActivity(Intent.createChooser(intent, text));
    } else {

        Toast.makeText(this, "App not found", Toast.LENGTH_SHORT)
                .show();
    }
}

Note : change *PACKAGE NAME OF THE APPLICATION as per your requirement like

Example : USE

Whatsapp: intent.setPackage("com.whatsapp");

Linkedin: intent.setPackage("com.linkedin.android");

Twitter: intent.setPackage("com.twitter.android");

Facebook: intent.setPackage("com.facebook.katana");

GooglePlus: intent.setPackage("com.google.android.apps.plus");

Shreshth Kharbanda
  • 1,777
  • 14
  • 24
Chaudhary Amar
  • 836
  • 8
  • 20
  • Thanks Amarbir for the quick reply. Your code uses the Chooser which I emphasized I dont' want to use. My app will have a list of contacts and it needs to send one Whatsapp msg to all of them in the background without using the chooser. – Soft Dev Jun 24 '15 at 07:03
  • http://stackoverflow.com/questions/17370965/how-to-broadcast-a-message-from-my-own-app-to-contacts-on-whatsapp – Chaudhary Amar Jun 24 '15 at 07:16