Currently I have a notification panel which has three buttons..one for opening the activity, one for pause upload and the other for resume upload.
I want the pause upload and resume upload to have a single button like the pause/play button in Google Music Player.
I have used this answer for building notification panel. Please suggest!
Notification Panel Class:
public NotificationPanel(Context parent) {
// TODO Auto-generated constructor stub
this.parent = parent;
nBuilder = new NotificationCompat.Builder(parent)
.setContentTitle("Notification Title")
.setSmallIcon(R.drawable.logo)
.setOngoing(true);
remoteView = new RemoteViews(parent.getPackageName(), R.layout.notification_layout);
//set the button listeners
setListeners(remoteView);
nBuilder.setContent(remoteView);
nManager = (NotificationManager) parent.getSystemService(Context.NOTIFICATION_SERVICE);
nManager.notify(2, nBuilder.build());
}
public void setListeners(RemoteViews view){
Intent stopNotify = new Intent(parent,HelperActivity.class);
stopNotify.putExtra("DO", "stop");
PendingIntent btn1 = PendingIntent.getActivity(parent, 0, stopNotify, 0);
view.setOnClickPendingIntent(R.id.notifyStopButton, btn1);
Intent pauseUpload = new Intent(parent,HelperActivity.class);
pauseUpload.putExtra("DO", "pause");
PendingIntent btn2 = PendingIntent.getActivity(parent, 1, pauseUpload, 0);
view.setOnClickPendingIntent(R.id.uploadPauseButton, btn2);
Intent resumeUpload = new Intent(parent,HelperActivity.class);
resumeUpload.putExtra("DO", "upload");
PendingIntent btn3 = PendingIntent.getActivity(parent, 2, resumeUpload, 0);
view.setOnClickPendingIntent(R.id.uploadResumeButton, btn3);
}
public void notificationCancel() {
nManager.cancel(2);
}