实际上我是android的新手,并且构建自定义通知。 在我的通知布局中,我有一个按钮。在其点击事件上,我需要更改某些系统设置。 但是当我调用MainActivity类之外的任何类时,它都没有响应 这是我的代码
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;
你能告诉我如何在这个场景中编程