2

I have a notification that has a custom xml view inside of it. It consists of 3 buttons, play pause and stop

enter image description here

how do I set up the onClick listener to react to button clicks for each of these three buttons?

I understand that you can only call setContentView() one time in each activity, so in that case I guess it is required to make a new activity for this custom xml layout and set the onclick listeners inside of that new activity. I am not sure how else to do that

the method that inflates the xml layout is inside of the Service class, this Service class also has the audio player (Android MediaPlayer) and a broadcast receiver nested inside of it.

This is part of the code in my Service class

  RemoteViews remoteviews = new RemoteViews("com.test.example", R.layout.custom_notifications);

     NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(AudioService.this)
               .setContent(remoteviews)
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle("My notification")
                .setContentText("Hello World!")
                .setOngoing(true);
Kevik
  • 9,181
  • 19
  • 92
  • 148
  • **Good answer here:** http://stackoverflow.com/questions/5479165/event-onclick-for-a-button-in-a-custom-notification?rq=1 – MaksymDovbnia Aug 19 '14 at 08:18

0 Answers0