0

I'm looking for the code to start WhatsApp call from my app and I haven't found any solution to that yet.

This must be possible because in Android contacts there is the Call number from WhatsApp option when you see any contact information.

Marcel Bro
  • 4,907
  • 4
  • 43
  • 70
Mdev07
  • 21
  • 1
  • 4

1 Answers1

-1

I believe this is what you are looking for:

Intent intent = new Intent(Intent.ACTION_DIAL);
/* sets the desired package for the intent */
intent.setPackage("com.whatsapp");
intent.setData(Uri.parse("tel:xxxxxxxxxx"))
startActivity(intent);

source; How to make a phone call using intent in Android?

Not sure if the package will automatically use the app though.

This will allow the user to select how they would like the perform the call. The whatsapp app should be setup to provide itself as a way of making calls.

Luple
  • 481
  • 3
  • 21
  • i want to make call from whatsapp ! – Mdev07 Mar 23 '18 at 14:27
  • This I believe is the safest solution. It will allow the user to choose which app to make the call with. If whatsapp isn't installed they can make the call with another phone service. Let me update though if you want to specify an app that will be used. – Luple Mar 23 '18 at 17:30
  • `android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=tel:xxxxxxxxxx pkg=com.whatsapp }` – Evren Yurtesen Jul 03 '19 at 13:29