Я только начал работать с уведомлениями, и теперь я пытаюсь удалить уведомление и запускать приложение после того, как уведомление было отправлено в центр уведомлений.
Я попытался работать со следующим кодом:
import android.app.NotificationManager;
public class ExpandNotification {
private int NOTIFICATION = 546;
private NotificationManager mNM;
public void onCreate() {
mNM.cancel(NOTIFICATION);
setContentView(R.layout.activity_on);
//Toast.makeText(this, "stopped service", Toast.LENGTH_SHORT).show();
}
Я думаю, что этот код выполняет другой класс при нажатии?
PendingIntent contentIntent = PendingIntent.getActivity(this, REQUEST_CODE, new Intent(this, ExpandNotification.class), 0);
Однако уведомление не исчезает, и приложение не запускается. Но я могу пронести его влево или вправо, чтобы удалить его, но это не то, что я хочу.