2

我正在尝试通过单击某个按钮从我的应用程序中使用 Google Duo 开始视频/音频通话。我可以在 WhatsApp 上成功启动音频/视频通话,但不能在 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);
4

1 回答 1

1

我终于找到了解决我的问题的方法。

 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();
    }
于 2019-01-24T11:45:22.390 回答