Developing for the new "Listen To" action in Android
I am finishing development of an application for Android to stream music from your personal music collection using DAAP and UPnP as well as other protocols at time permits.
My question is: How do I enable my app to respond to the new "Listen To" voice开发者_运维知识库 command in Android?
I have searched all over the place and can't figure it out.
I assume it's a broadcast receiver, but for the life of me, I can't find which one.
Any help is much appreciated.
Like the link @JoshLee mentioned explains, you just need to register your application's new intent in the application's manifest file "intent-filters" section such as:
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
and then make sure you:
import android.app.SearchManager;
you might also want to do something with the query so you can grab it like this:
String query = getIntent().getStringExtra(SearchManager.QUERY);
but you should probably encase that in a try/catch and handle any exceptions or cases where query == null.
精彩评论