Skip to content

Instantly share code, notes, and snippets.

@lzsucceed
Created May 19, 2014 23:50
Show Gist options
  • Save lzsucceed/66097338cf2aea10b503 to your computer and use it in GitHub Desktop.
Save lzsucceed/66097338cf2aea10b503 to your computer and use it in GitHub Desktop.
Intent playpause = new Intent(context, MusicPlayerService.class);
playpause.putExtra(MusicPlayerService.REQUEST_TYPE, MusicPlayerService.PLAY_PAUSE);
playpause.putExtra("from_widget", true);
PendingIntent pendingIntent4 = PendingIntent.getService(context, 0, playpause,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.playpause, pendingIntent4);
Intent prev = new Intent(context, MusicPlayerService.class);
prev.putExtra("from_widget", true);
prev.putExtra(MusicPlayerService.REQUEST_TYPE, MusicPlayerService.REWIND);
PendingIntent pendingIntent2 = PendingIntent.getService(context, 1, prev, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.prev, pendingIntent2);
Intent next = new Intent(context, MusicPlayerService.class);
next.putExtra("from_widget", true);
next.putExtra(MusicPlayerService.REQUEST_TYPE, MusicPlayerService.NEXT_SONG);
PendingIntent pendingIntent3 = PendingIntent.getService(context, 2, next, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.next, pendingIntent3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment