I am making an app that plays a radio stream, and when it starts playing, I create a custom notification with 2 buttons, one to pause / play and another to remove the notification and stop the stream, but I did not succeed and the buttons do nothing, I read about PendingIntent and BroadcastReceiver but to no avail, can anyone help me?
Button codes:
Intent it = new Intent(MyService.this,MainActivity.class);
it.setAction("tocando");
it.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi = PendingIntent.getActivity(MyService.this, 0, it, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentIntent(pi);
Intent itt = new Intent(getApplicationContext(),MyBroadcast.class);
itt.putExtra("comand", "pause");
PendingIntent pitt = PendingIntent.getBroadcast(getApplicationContext(),23424324, itt, 0);
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notificacao);
view.setOnClickPendingIntent(R.id.pause, pitt);
builder.setContent(view);
Notification not = builder.build();