How to programmatically initiate a Google Now voice search?

后端 未结 3 512
说谎
说谎 2020-12-08 11:18

I want to start a Google Now voice search when the user presses a button. However, I can\'t find the Intent to start the search in the docs.

Does a

3条回答
  •  醉酒成梦
    2020-12-08 11:54

    Use ACTION_RECOGNIZE_SPEECH:

    private static final int RECOGNIZER_REQ_CODE = 1234;
    
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    startActivityForResult(intent, RECOGNIZER_REQ_CODE);
    

    Please note that you have to use startActivityForResult() as startActivity() is not supported. See the above linked docs for details.

提交回复
热议问题