Tengo un servicio en ejecución que actualiza una notificación en la barra de notificaciones cuando recibe un mensaje que dice que tiene que ser cambiado.Android - java.lang.IllegalArgumentException: contentIntent error requerido causado por la notificación?
Sin embargo, me sale el siguiente error a veces, cuando la notificación se va a actualizar
java.lang.IllegalArgumentException: contentIntent required
Aquí está mi código:
configuración variable
int icon = R.drawable.notification;
CharSequence tickerText = "Test";
long when = System.currentTimeMillis();
PendingIntent contentIntent;
Notification notification = new Notification(icon, tickerText, when);
NotificationManager mNotificationManager;
NotificationManager Creación
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
Creación Notificación
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);
Actualización de Notificación
notification.icon = R.drawable.notification2;
notification.setLatestEventInfo(getApplicationContext(), "Registered", "Test", contentIntent);
mNotificationManager.notify(1, notification);
Así que algo está pasando mi contentIntent en algún momento, ¿sería correcto?
Se declara en la parte superior de mi clase de servicio como una variable miembro y no se utiliza en ningún otro lugar en el código aparte de lo mostrado anteriormente, entonces ¿dónde podría restablecerse a nulo?
No todas las versiones de Android requieren esto. Tenía un caso que funcionaba bien en todo excepto en Kindle Fire. –
¿Sabe lo que hago si no deseo intentar disparar al hacer clic en la notificación? Solo quiero que esté allí mientras el sistema está haciendo algo y todo irá por sí mismo. –
para mi caso, que muestra notificación desde el servicio, que sería mBuilder.setContentIntent (PendingIntent.getActivity (this, 0, new Intent(), 0)); – toantran