1

I have initiated a WhatsApp video call from my Android app as shown here.

String contactNumber = "Your Contact Number"; // to change with real value

Cursor cursor = context.getContentResolver ()
.query (
    ContactsContract.Data.CONTENT_URI,
    new String [] { ContactsContract.Data._ID },
    ContactsContract.RawContacts.ACCOUNT_TYPE + " = 'com.whatsapp' " +
        "AND " + ContactsContract.Data.MIMETYPE + " = 'vnd.android.cursor.item/vnd.com.whatsapp.video.call' " +
        "AND " + ContactsContract.CommonDataKinds.Phone.NUMBER + " LIKE '%" + contactNumber + "%'",
    null,
    ContactsContract.Contacts.DISPLAY_NAME
);

if (cursor == null) {
// throw an exception
}

long id = -1;
while (cursor.moveToNext()) {
id = cursor.getLong (cursor.getColumnIndex (ContactsContract.Data._ID));
}

if (!cursor.isClosed ()) {
cursor.close ();
}


Intent intent = new Intent ();
intent.setAction (Intent.ACTION_VIEW);

intent.setDataAndType (Uri.parse ("content://com.android.contacts/data/" + id), "vnd.android.cursor.item/vnd.com.whatsapp.voip.call");
intent.setPackage ("com.whatsapp");

startActivity (intent);

This opens WhatsApp and the video call starts. Now the user returns to my app to continue the workflow, while the video call continues as an overlay on the screen. After a while I want that the user should be able to disconnect the WhatsApp call from my app.

Can I also disconnect the video call from my app programatically? Otherwise the call keeps running in the background.

S_S
  • 1,276
  • 4
  • 24
  • 47
  • Only if there is an Uri scheme registered for that in whats App . Which i am afraid will not be there (IMO) .. Because i seems no sense to me to provide such Scheme .. If User is On call he/she can disconnect whenever they want .. Automatic disconnection is not good for UX . – ADM Apr 19 '20 at 03:22
  • The use case involves making a WhatsApp call from the app and completing the workflow in the app during which the WhatsApp call shows as a screen overlay. Now instead of disconnecting the call if the user closes the overlay the call continues in WhatsApp. Is there any solution to handle this? – S_S Apr 19 '20 at 05:37

0 Answers0