Developing a new Listen action on Android

I am completing the development of an Android application for streaming music from your personal music collection using DAAP and UPnP, as well as other time protocols.

My question is: How do I enable the app to respond to the new โ€œListenโ€ voice command on Android?

I searched everywhere and cannot understand.

I suppose this is a broadcast receiver, but for the life of me I cannot find which one.

Any help is greatly appreciated.

+7
android voice-recognition
source share
1 answer

As the @JoshLee link is mentioned, you just need to register a new application in the intent filters application manifest file, for example:

<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" /> 

and then make sure you:

 import android.app.SearchManager; 

you can also do something with the request so that you can capture it like this:

String query = getIntent().getStringExtra(SearchManager.QUERY);

but you should probably wrap this in try / catch and handle any exceptions or cases where query == null.

+1
source share

All Articles