2

I am trying to start video/audio call using Google Duo from my app by clicking a certain button. I can successfully start audio/video call on WhatsApp but not on Google Duo.

  long id= 133;

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

    // the _ids you save goes here at the end of /data/
    intent.setDataAndType(Uri.parse("content://com.android.contacts/data/"+id),
            "vnd.android.cursor.item/com.google.android.apps.tachyon.phone.audio");
    intent.setPackage("com.google.android.apps.tachyon");
    startActivity(intent);
JSON C11
  • 11,272
  • 7
  • 78
  • 65
Waheed Abbas
  • 187
  • 1
  • 4
  • 18

1 Answers1

1

I finally found the solution to my problem.

 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();
    }
Waheed Abbas
  • 187
  • 1
  • 4
  • 18
  • Do you want the code to get the ID from phone number? – Waheed Abbas Jul 22 '19 at 06:41
  • I need to start duo video call from other app – sterin jacob Jul 24 '19 at 04:41
  • intent.setComponent(new ComponentName(packageName, "com.google.android.apps.tachyon.ContactsAudioActionActivity")); is causing show unable to resolve packageName so I changed to intent.setComponent(new ComponentName(" com.google.android.apps.tachyon","com.google.android.apps.tachyon.ContactsAudioActionActivity")); it is causing different exception – sterin jacob Jul 25 '19 at 06:29
  • Unable to find explicit activity class { com.google.android.apps.tachyon/com.google.android.apps.tachyon.ContactsAudioActionActivity}; have you declared this activity in your AndroidManifest.xml? Can you provide AndroidManifest.xml file – sterin jacob Jul 25 '19 at 06:31
  • https://github.com/sterin501/Andriod Please check it – sterin jacob Jul 26 '19 at 09:15
  • There is a space in package name on line 40. And you need to add "Call_Phone" permission in your manifest file. Use "Data.Content_uri" in getID function and also before storing the ID compare the mimetype with "vnd.android.cursor.item/com.google.android.apps.tachyon.phone" and then store it. – Waheed Abbas Jul 26 '19 at 13:05
  • Follow up question : https://stackoverflow.com/questions/57230867/vnd-android-cursor-item-com-google-android-apps-tachyon-phone-is-missing-in-mime – sterin jacob Jul 27 '19 at 09:36