简体   繁体   English

如何以编程方式启动Google智能助理?

[英]How to start Google Assistant programmatically?

I have tried every simple combo I have found but not sure how to do this. 我已经尝试了我找到的每个简单的组合,但不知道如何做到这一点。 I even tried to simulate the home long press but you get google now voice, lookint at logcat it shows this 我甚至试图模拟家庭长按,但你得到谷歌现在的声音,看着logcat它显示这一点

com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity com.google.android.googlequicksearchbox / com.google.android.apps.gsa.staticplugins.opa.OpaActivity

but not sure if this is what I am looking for or how to replicate it. 但不确定这是我正在寻找的或如何复制它。

这有效:

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启动助手时发现了一些东西:

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. 虽然这不会抛出ActivityNotFoundException,但它会抛出Permission Denial。 This is shown to happen because Google Assistant must be launched from the googlequicksearchbox package from above. 这显示是因为必须从上面的googlequicksearchbox包启动Google智能助理。 Hopefully this will change when/if they release an API for it. 希望当它们为它发布API时会发生变化。 Fingers crossed. 手指交叉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM