Android: Register another app as mediaButtonEvenReceiver -
in android, possible register app receiver media button events?
for example, want start playing music google play music programmatically (ie: without leaving app , launching google play music). i've tried:
componentname myeventreceiver = new componentname("com.google.android.music", "com.google.android.music.mediabuttonintentreceiver"); audiomanager myaudiomanager = (audiomanager) getsystemservice(context.audio_service); myaudiomanager.registermediabuttoneventreceiver(myeventreceiver); // build pendingintent remote control client intent mediabuttonintent = new intent(intent.action_media_button); mediabuttonintent.setcomponent(myeventreceiver); pendingintent mediapendingintent = pendingintent.getbroadcast(getapplicationcontext(), 0, mediabuttonintent, 0); // create , register remote control client remotecontrolclient myremotecontrolclient = new remotecontrolclient(mediapendingintent); myaudiomanager.registerremotecontrolclient(myremotecontrolclient);
i error, makes sense:
registermediabuttoneventreceiver() error: receiver , context package names don't match.
is possible other way?
my app playlist manager able launch google music. long google music has picked playlist through ascan, plays playlist. have found though treats playorder not numeric text 1, 10, 11,2.
public void playselectedplaylist(string playlistname) { intent intent = new intent( mediastore.intent_action_media_play_from_search); intent.putextra(mediastore.audio.playlists.entry_content_type, "android.intent.extra.playlist" ); intent.putextra(searchmanager.query, playlistname); intent.putextra(mediastore.extra_media_focus, "vnd.android.cursor.item/playlist"); if (intent.resolveactivity(getpackagemanager()) != null) { startactivity(intent); }else{ dotoast("sorry, no app found service request", context); } }
the intent intent_action_media_play_from_search , finds apps have in manifest.xml file. far poweramp shows up.
have @ playlist manager theoklink. google play music play playlist without problems.
Comments
Post a Comment