views:

326

answers:

2

I am trying to build an Android Service that should get notified when the user starts playing an MP3. I checked LogCat when I start playing a song and saw that the following Intent is logged:

Intent { act=com.android.music.PLAYBACK_VIEWER flg=0x4000000 cmp=com.android.music/.MediaPlaybackActivity }

I couldn't figure out how to write an IntentFilter to let my Service know that this event has occurred and let me know the name of the song that will be played. I searched Android reference but could not find anything on PLAYBACK_VIEWER.

Thanks,

C

A: 

I would do neither. First, none of this is part of the SDK and so may change at any point. Second, this will only work for the built-in media player application, not any third-party or OEM-supplied media players, and I expect more people to gravitate to those.

CommonsWare
A: 

Similarly I am trying to build an Android Service that should be notified when a ringtone starts playing. Now I can get this change in status from the TelephonyManager and check the default ringtone etc. in the RingtoneManager, but I cannot appear to find out exactly which ringtone is playing (after all users can assign separate ringtones to individual contacts)...

So forgive me, but I am just curious if you solved this problem in any way as I suspect the answer relates to what I am trying to do. Many thanks. Clive

Clive
I agreed with the answer given above and gave up on it. No API call for this exists and although you can find out and try to intercept the intent fired when user starts playing it may not be platform/release dependent.
recipriversexclusion