Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 image 370
Greg Lamoree Avatar asked Sep 12 '10 23:09

Greg Lamoree


1 Answers

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.

like image 174
AndrewPK Avatar answered Sep 28 '22 22:09

AndrewPK