List of usage examples for android.support.v4.media.session MediaSessionCompat FLAG_HANDLES_TRANSPORT_CONTROLS
int FLAG_HANDLES_TRANSPORT_CONTROLS
To view the source code for android.support.v4.media.session MediaSessionCompat FLAG_HANDLES_TRANSPORT_CONTROLS.
Click Source Link
From source file:com.rks.musicx.services.MusicXService.java
@Override public void mediaLockscreen() { mediaSessionLockscreen = new MediaSessionCompat(this, TAG); mediaSessionLockscreen.setCallback(new MediaSessionCompat.Callback() { @Override/*from w ww . j av a 2 s . co m*/ public void onPlay() { play(); } @Override public void onPause() { pause(); } @Override public void onSkipToNext() { playnext(true); } @Override public void onSkipToPrevious() { playprev(true); } @Override public void onStop() { stopSelf(); } @Override public void onSeekTo(long pos) { seekto((int) pos); } @Override public boolean onMediaButtonEvent(Intent mediaButtonEvent) { if (mediaButtonReceiver != null) { mediaButtonReceiver.onReceive(MusicXService.this, mediaButtonEvent); } return true; } }); mediaSessionLockscreen.setFlags( MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); ComponentName buttonCom = new ComponentName(getApplicationContext(), MediaButtonReceiver.class); Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(buttonCom); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); mediaSessionLockscreen.setMediaButtonReceiver(pendingIntent); mediaSessionLockscreen.setActive(true); }