实际上我是 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;
你能告诉我如何在这种情况下编程吗