0

Actually I am new to android, and building a custom notification. in my notification layout I have a button . on its click event i need to change certain system settings. But when i invoke any class other then MainActivity class , it dosen't respond here is my code

 int icon = R.drawable.notifyicon;
    long when = System.currentTimeMillis();
    Notification notification = new Notification(icon, "Custom Notification", when);

    NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
    contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
    contentView.setTextViewText(R.id.title, "Custom notification");
    //contentView.setTextViewText(R.id.text, "This is a custom layout");
    Intent notificationIntent1 = new Intent(this,notify.class);//Here if I write MainActivity.class it works
    PendingIntent contentIntent1 = PendingIntent.getActivity(this, 0, notificationIntent1, 0);
    contentView.setOnClickPendingIntent(R.id.button2, contentIntent1);
    /*
    Intent notificationIntent = new Intent(this, NotificationReceiverActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);*/


    notification.contentView = contentView;

    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

  notification.contentIntent = contentIntent;

Can you tell me how to program in this scenario

1 Answers1

0

I am stuck in the same problem check many link but to no outcome maybe you can figure something out here are the links:

Link 1

Link 2

Link 3

Link 4

Link 5

I am new to android too, maybe we can help each other out.

Community
  • 1
  • 1
Syed Raza Mehdi
  • 4,067
  • 1
  • 31
  • 47
  • This worked for me dear check this link out this http://stackoverflow.com/questions/12438209/handling-buttons-inside-android-notifications – Syed Raza Mehdi Feb 21 '14 at 09:44