I want to send message to multiple contacts at once , via whatsapp. I know that it is posible via whatsapp broadcast, but problem is I dont know how to realize it by code, in android studio. I searched about it, but didn't find anything. Does anyone knows how to do it?
Asked
Active
Viewed 6,875 times
2 Answers
1
To send a message from your app to multiple contacts in WhatsApp
String message = "Health worker uploaded a data";
Context context_new=this.getApplicationContext();
packageManager = context_new.getPackageManager();
Intent i = new Intent(Intent.ACTION_VIEW);
try {
//only message and ability to send message to multiple nos.
String url = "https://api.whatsapp.com/send?text=" + URLEncoder.encode(message, "UTF-8");
i.setPackage("com.whatsapp");
i.setData(Uri.parse(url));
if (i.resolveActivity(packageManager) != null) {
context_new.startActivity(i);
Log.d(TAG, "Watsapp message successful"+ "passed");
}
} catch (Exception e){
e.printStackTrace();
Log.d(TAG, "Watsapp message failed"+ "failed");
}

Prajwal Waingankar
- 2,534
- 2
- 13
- 20
0
here i m sharing audio file to multiple contact via whatsapp..
lblshare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String valueofpathh = recordName.getText().toString();
File filee = new File(valueofpathh);
try {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("audio/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(filee));
startActivity(sendIntent);
} catch (NoSuchMethodError | IllegalArgumentException | NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
});
i hope its help you to understand.
here valueOfPath is my string that contain my device sdcard folder path, so i can get all audio file from that path.
if you have only message file to send then change intent type:
sendIntent.setType("text/plain");
try to look at this link:

Community
- 1
- 1

Sagar Chavada
- 5,169
- 7
- 40
- 67