How to Extend Google Now Voice Commands in Android

2019-04-08 23:58发布

I recently installed the Google Now Launcher on my Nexus 4, and it got me thinking about how I could use it to interact with my own apps. While I can open my app by asking for it by title, I was wondering if there's a way to intercept the voice commands (possibly through a broadcast receiver) so I can say something like "turn off living room light" to send a signal to an Arduino to turn off the light in a room across the house? On the same note, I haven't been able to find the documentation for Google Now, so if that's out there I would love to see the link for it so I can just read what's available from the source.

1条回答
别忘想泡老子
2楼-- · 2019-04-09 00:10

Yes. You can do it using the Android-Intent model. Google Now fires various intents after parsing your command, and if the phone has an app registered to handle such intent, google now will who user the options to execute the command. Common Intents are: Alarm, Fitness, Media https://developer.android.com/guide/components/intents-common.html#Now

查看更多
登录 后发表回答