7

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.

Emmanuel Devaux
  • 3,327
  • 4
  • 25
  • 30
  • if the stock music app responds to it I would check the source code for it and see what receiver they are implementing. – Nathan Schwermann Sep 13 '10 at 01:46
  • 3
    Explained on the Android Developers Blog: http://android-developers.blogspot.com/2010/09/supporting-new-music-voice-action.html – Josh Lee Sep 14 '10 at 22:28

1 Answers1

1

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.

AndrewPK
  • 6,100
  • 3
  • 32
  • 36