How to Extend Google Now Voice Commands in Android with Custom Actions

空扰寡人 提交于 2019-12-21 17:18:23

问题


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:


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



来源:https://stackoverflow.com/questions/22185345/how-to-extend-google-now-voice-commands-in-android-with-custom-actions

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