简体   繁体   中英

How to open Google Assistant from an app?

I am relatively new to android and I am working on an app which requires me to open google assistant from my own application. I do not intend to add conversations and my sole purpose is to mimic the "Home Button Long Press" which opens up Google Assistant. Any way I can do that? Thanks!

You can try use this ACTION_VOICE_COMMAND that that activity action is to start Voice Command.

In your code:

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

Try this one.. It works

    `$`
    startActivity(new 
  Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
val intent = Intent(Intent.ACTION_VIEW)
intent.data=Uri.parse("market://details?id=com.google.android.apps.googleassistant")
activity.startActivity(intent)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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