8

I am looking for a way to start a video call in either Hangouts or Duo. There seems to be 0 documentation regarding what intents should be used. Does anyone have an idea?

JSON C11
  • 11,272
  • 7
  • 78
  • 65
Konstantin Milyutin
  • 11,946
  • 11
  • 59
  • 85

3 Answers3

6

Let's consider Duo here.

Research

1.First of all, to find out the intent, you should activate the USB debug mode on your phone - please refer to this answer to find out how to do it.

2.Then, connect your phone to your computer so that you could see the logcat from your device (debug level should be info).

3.Open Contacts(from Google) and find a contact to whom you can call using Duo. Now, start the call and search for com.google.android.apps.tachyon. There will be a couple of matches but the important one looks something like:

START u0 {act=com.google.android.apps.tachyon.action.CALL typ=null flg=0x0 cmp=ComponentInfo{com.google.android.apps.tachyon/com.google.android.apps.tachyon.ExternalCallActivity}} from uid 10031

4.So, once you know the component info for your Duo app, just add the following code in your app from where you'd like to start a video call.

val intent = Intent()
intent.setAction("com.google.android.apps.tachyon.action.CALL")
intent.setClassName("com.google.android.apps.tachyon",
    "com.google.android.apps.tachyon.ExternalCallActivity")
startActivity(intent)

5.You'll see a video call screen with possible contacts.

Conclusion

If you'd like to find out how to start a video call or chat or something else, try to do the same as above - do it manually first and check what intents (and arguments) are used in those cases.

Community
  • 1
  • 1
Anatolii
  • 14,139
  • 4
  • 35
  • 65
  • For me this results in a new activity of type `com.google.android.apps.tachyon.action.PRECALL_ACTIVITY` being fired, while calling from the dialer results in a new activity of type `com.google.android.apps.tachyon.action.CALL` being fired. Both have class name of `com.google.android.apps.tachyon/.ProcessedCallRequestActivity`. The manual activity firing attempt results in a pre-call screen with the correct contact and a 'Video Call' button, while the dialer's intent successfully starts a video call. The intents look the same in logcat. Any ideas? – Egal Mar 16 '20 at 16:15
3

There isn't any API documentation available for google duo app integration right now.

You can use this code it's working for starting a duo call.

String data = "content://com.android.contacts/data/" + ID;
// Build the intent
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
// the _ids you save goes here at the end of /data/id
intent.setData(Uri.parse("content://com.android.contacts/data/" + ID));
//For audio call
intent.setComponent(new ComponentName(packageName, "com.google.android.apps.tachyon.ContactsAudioActionActivity"));
//use this for video call
//intent.setComponent(new ComponentName(packageName, "com.google.android.apps.tachyon.ContactsVideoActionActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Verify it resolves
PackageManager packageManager = context.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
// Start an activity if it's safe
if (isIntentSafe) {
    context.startActivity(intent);
    Toast.makeText(context, "Opening Duo", Toast.LENGTH_SHORT).show();
}

Or You can use following approach passing telephone number

Intent intent = new Intent();
intent.setPackage("com.google.android.apps.tachyon");
intent.setAction("com.google.android.apps.tachyon.action.CALL");
intent.setData(Uri.parse("tel:1234567890"));
startActivity(intent);
Muzammil Husnain
  • 1,218
  • 1
  • 10
  • 24
0

A) HangoutUrlHandlerActivity, ShortlinkUrlHandlerActivity and ConversationUrlHandlerActivity are available for receiving Intent with an Uri.

What I have so far, which is actually working, but only for ongoing conversations & video calls:

a) opening an ongoing conversation:

void joinConversation(@NonNull String conversationId) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = new Uri.Builder().scheme("content").authority("hangouts.google.com").appendPath("chat").appendPath(conversationId).build();
    intent.setClassName("com.google.android.talk", "com.google.android.apps.hangouts.phone.ConversationUrlHandlerActivity");
    intent.setDataAndType(uri, "vnd.google.android.hangouts/vnd.google.android.hangout_whitelist");
    startActivity(intent);
}

b) joining an ongoing video call (the ID comes from hangouts.google.com/hangouts/_/meet):

void joinHangout(@NonNull String callId) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = new Uri.Builder().scheme("content").authority("g.co").appendPath("hangout").appendPath(Uri.encode(callId)).build();
    intent.setClassName("com.google.android.talk", "com.google.android.apps.hangouts.phone.ShortlinkUrlHandlerActivity");
    intent.setDataAndType(uri, "vnd.google.android.hangouts/vnd.google.android.hangout_whitelist");
    startActivity(intent);
}

If direct invites should not be possible - one could still schedule calls through the Calendar API, where one gets the callId from, so that one can join the Hangout once it is scheduled. Google Meet does not even support direct invites, but only through Google Calendar appointments.


Based upon the comment from @Mir Milad, I've managed to at least create a new text conversation; but still nothing that would ring someone up (it notifies as soon as the first message had been sent):

/** @param googleUserId that 21 digit Google user ID, aka Gaia ID  */
void createConversation(@NonNull String googleUserId) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = new Uri.Builder().scheme("content").authority("hangouts.google.com").appendPath("chat").appendPath("person").appendPath(googleUserId).build();
    intent.setClassName("com.google.android.talk", "com.google.android.apps.hangouts.phone.ConversationUrlHandlerActivity");
    intent.setDataAndType(uri, "vnd.google.android.hangouts/vnd.google.android.hangout_whitelist");
    startActivity(intent);
}

As far as I can tell, there is no such thing as an explicit "call me" URL for Hangouts. And even web-based, the Hangout is being initiated with two Gaia ID, which then result in a room name to join. Even Google's own Hangouts Dialer seems to be broken, when looking at the recent comments.


B) For Google Duo, this was already answered here.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • 1
    The question here is about looking for a way to START a video call, NOT to join an ongoing one. You answer is misleading! I should have down-voted you, but I won't do something awful like you did to some other people here. – Harry Timothy Feb 23 '20 at 08:13
  • @harrytmthy It is barely misleading, when it explicitly states it... in case one would read. This at least makes it clear, that one cannot directly video-call - except there is an URL which would do so. Being down-voted for providing original content is questionable, since it took me quite a while to find these intents and URL arguments. This question are actually **two** questions, not one. – Martin Zeitler Feb 25 '20 at 13:43