play/pause button image in notification ,Android
This should work. Just make your notification
and notificationManager
a static global variable.
public class RemoteControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(action.equalsIgnoreCase("com.example.test.ACTION_PLAY")){
if(mediaplayer.isPlaying()){
mediaplayer.pause();
notificationView.setImageViewResource(R.id.button1, R.drawable.play);
notification.contentView = notificationView;
notificationManager.notify(1, notification);
}
else {
mediaplayer.start();
notificationView.setImageViewResource(R.id.button1, R.drawable.pause);
notification.contentView = notificationView;
notificationManager.notify(1, notification);
}
}
}
}
You have to set your notification.contentView to the new remoteView after it was changed so it can update the notification view itself.
Meaning, after you receive the action in your BroadcastReceiver, re-build your notification with the desired button display ( pause or play )
Hope this helps