mhmdbsh
mhmdbsh

Reputation: 71

How to send media action button to current player?

Is there any way to send a media action button to current media player (like Walkman or google play music) to play and pause or next and previous song.

actually i want to create a simple remote control

Upvotes: 1

Views: 419

Answers (1)

mhmdbsh
mhmdbsh

Reputation: 71

i find my answer here

if (mAudioManager == null) mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);

KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY);
mAudioManager.dispatchMediaKeyEvent(event);

Upvotes: 4

Related Questions