7

I'm looking for a way to start a videocall from my Android app written in Delphi 10.3. For that I want to use Android intents to 3rd-party app (WhatsApp or Skype).

Here's what I have already tried. I'm using 123 as contacts id, expecting that even if it is not a valid id, WhatsApp should still open and warn about that:

Based on https://stackoverflow.com/a/38674897 - nothing happens

Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setData(StrToJURI('content://com.android.contacts/data/123'));
Intent.setType(StringToJString('vnd.android.cursor.item/vnd.com.whatsapp.voip.call'));

Based on https://stackoverflow.com/a/46049004 - nothing happens

Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setData(StrToJURI('content://com.android.contacts/data/123'));
Intent.setType(StringToJString('vnd.android.cursor.item/vnd.com.whatsapp.video.call'));
Intent.setPackage(StringToJString('com.whatsapp'));

Fix suggests to disuse SetType https://stackoverflow.com/a/28244207 - nothing happens

Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
Intent.setDataAndType(
  StrToJURI('content://com.android.contacts/data/123'),
  StringToJString('vnd.android.cursor.item/vnd.com.whatsapp.video.call'));
Intent.setPackage(StringToJString('com.whatsapp'));

Skype code sample based on https://stackoverflow.com/a/14294299 - it opens Skype, but does not open chat/call on first try. If I switch to my app while Skype is open in background, on a second try it will start videocall.

Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
//Intent.setData(StrToJURI('skype:username?call&video=true'));
Intent.setData(StrToJURI('skype:username'));

Trying videocall action - pops up a message "Receiver not found"

Intent := TJIntent.Create;
Intent.setAction(StringToJString('com.android.phone.videocall'));
Intent.setData(StrToJURI('skype:username'));

Intent := TJIntent.Create;
Intent.setAction(StringToJString('com.android.phone.videocall'));
Intent.setData(StrToJURI('tel:123456789'));

All intents are executed with:

if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
  MainActivity.startActivity(Intent)
else
  ShowMessage('Receiver not found');

How do I make a videocall from Android App written in Delphi?

Kromster
  • 7,181
  • 7
  • 63
  • 111

1 Answers1

0

It is not a dephi specific issue. Your code doesn't work even when its in java.(It shows receiver not found)

See the following. They are in java but I guess they can point you to the right path

  1. android-make whatsapp call
  2. Android: Retrieve contact name from phone number
  3. https://developer.android.com/training/permissions/requesting#java
Dr Deo
  • 4,650
  • 11
  • 43
  • 73
  • Thanks for the links, however **they don't seem to answer the question**. 1. Has the same code that is already in the question. 2. Retrieving contacts name is not the case. 3. Obtaining permissions is not the case either. – Kromster Jan 17 '19 at 04:50