我试图通过单击某个按钮从我的应用程序使用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);

最佳答案

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

 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();
    }

关于java - 没有应用程序可以处理此操作Google Duo,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50897179/

10-10 10:06