Android App Integrated with OK Google

前端 未结 3 725
北恋
北恋 2020-12-02 17:38

Is there a way to issue a voice command something like:

OK GOOGLE ASK XXX Some App Specific Question or Command

And have it launch \"APP\" with the recognize

3条回答
  •  青春惊慌失措
    2020-12-02 18:06

    To integrate "OK Google" in your app is easy with following two steps.

    First we need to declare in the manifest File

    
                    
                    
                
    />
    

    Now we need to declare in the Activity onCreate

     if (getIntent().getAction() != null && getIntent().getAction().equals("com.google.android.gms.actions.SEARCH_ACTION")) {
                query = getIntent().getStringExtra(SearchManager.QUERY);
                Log.e("Query:",query);   //query is the search word              
            }
    

    User should follow the syntax to detect by "Ok google", When a user says, “OK Google, search for phrase on app name”, Google first checks if there is an app called app name installed which has declared itself to be capable of handling such queries.

提交回复
热议问题