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.