Android - java.lang.IllegalArgumentException: contentIntent требуется ошибка, вызванная уведомлением?

У меня запущена служба, которая обновляет уведомление в панели уведомлений, когда получает сообщение о том, что оно должно быть изменено.

Однако иногда я получаю следующую ошибку при обновлении уведомления

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 где-то вдоль линии, это будет правильно?

Он объявлен в верхней части моего класса Service как переменная-член и не используется где-либо еще в коде, кроме показанного выше, так где же он может быть сброшен до нуля?

Ответы на вопрос(4)

Ваш ответ на вопрос