miércoles, 14 de julio de 2010

Documentación en Android: NotificationManager

En las FAQs de la dev guide de Android, mas precisamente en el howto de las notificaciones, podemos ver el siguiente codigo:


static void setNewMessageIndicator(Context context, int messageCount){
   // Get the static global NotificationManager object.
   NotificationManager nm = NotificationManager.getDefault();

   // If we're being called because a new message has been received,    // then display an icon and a count. Otherwise, delete the persistent    // message.    if (messageCount > 0) {       nm.notifyWithText(myApp.NOTIFICATION_GUID,      // ID for this notification.                 messageCount + " new message" + messageCount > 1 ? "s":"", // Text to display.                 NotificationManager.LENGTH_SHORT); // Show it for a short time only.    } }


El gran problema es que el metodo NotificationManager.getDefault() no existe. El uso correcto de las notificaciones lo podemos ver aquí. Donde se observa que la manera de acceder al NotificationManager es:


String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);



Gracias al equipo de documentación de google!

No hay comentarios: