How to start Google Assistant programmatically?

扶醉桌前 提交于 2019-11-29 14:12:01
yausername

This works:

startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

So I've been trying to do the same thing, and just discovered something when I'm trying to launch the Assistant with an Intent like this:

Intent launchIntent = new Intent(Intent.ACTION_VIEW);
        launchIntent.setPackage("com.google.android.googlequicksearchbox");
        launchIntent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.apps.gsa.staticplugins.opa.OpaActivity");
startActivity(launchIntent);

Although this doesn't throw an ActivityNotFoundException, it does throw a Permission Denial. This is shown to happen because Google Assistant must be launched from the googlequicksearchbox package from above. Hopefully this will change when/if they release an API for it. Fingers crossed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!