How to start Google Assistant programmatically?
Asked Answered
K

2

7

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

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.

Kirkkirkcaldy answered 20/11, 2016 at 20:45 Comment(0)
C
15

This works:

startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
Colleencollege answered 29/4, 2017 at 21:27 Comment(1)
Can you ask question along with the intent ACTION_VOICE_COMMAND?Crimpy
P
1

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.

Patch answered 5/12, 2016 at 20:45 Comment(2)
Yes, i tried that already. You can bypass that with ROOT. and it works just fine but requires root.Kirkkirkcaldy
com.google.android.googlequicksearchbox is not Google Assistant. Its the Google app.Mathematical

© 2022 - 2024 — McMap. All rights reserved.