У меня есть сервис, работающий, который обновляет уведомление в панели уведомления, когда она получает сообщение, говоря, что она должна быть изменена.
Однако я получаю следующую ошибку иногда, когда уведомление должно быть обновлено
java.lang.IllegalArgumentException: contentIntent required
Вот мой код:
Переменная установка
int icon = R.drawable.notification;
CharSequence tickerText = "Test";
long when = System.currentTimeMillis();
PendingIntent contentIntent;
Notification notification = new Notification(icon, tickerText, when);
NotificationManager mNotificationManager;
Создание NotificationManager
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
Создание уведомления
Intent notificationIntent = new Intent(this, TestsApp.class);
contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.icon = R.drawable.notification3;
notification.setLatestEventInfo(this, "Registering", "Test", contentIntent);
mNotificationManager.notify(1, notification);
Обновление уведомления
notification.icon = R.drawable.notification2;
notification.setLatestEventInfo(getApplicationContext(), "Registered", "Test", contentIntent);
mNotificationManager.notify(1, notification);
Таким образом, что-то происходит мой contentIntent где-нибудь вдоль строки, которая была бы корректна?
Это объявляется во главе моего Класса обслуживания как членская переменная и не используется больше нигде в коде кроме показанного выше, поэтому где это могло становиться сброшенным к пустому указателю?