Problema con mensaje notificacion

Para dar las gracias debes entrar o registrarte en el foro

Recién llegado
Recién llegado
Mensajes: 4 Agradecido: 0
06 Ago 2012, 12:32# 1

Hola.

Tengo un método que crea una notificación con un mensaje recibido por parámetro en la que el usuario al hacer clic se habre una nueva ventana con dicho mensaje.

El problema lo tengo cuando se crea una segunda notificación, haya abierto la primera o no, y es que en esta nueva pantalla que se abre siempre me muestra el mensaje de la primera notificación, aunque en la descripción de la notificación si me pone el mensaje correcto.

Os dejo el código y espero que me podáis ayudar ya que no se que hago mal

CODIGO CREACION NOTIFICCION

@SuppressWarnings("deprecation")
private void mostrarNotificacion(Context context, String msg)
{

//Obtenemos una referencia al servicio de notificaciones
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notManager =
(NotificationManager) context.getSystemService(ns);

//Configuramos la notificación
int icono = android.R.drawable.stat_sys_warning;
CharSequence textoEstado = "Alerta!";
long hora = System.currentTimeMillis();

Notification notif =
new Notification(icono, textoEstado, hora);

//Configuramos el Intent
Context contexto = context.getApplicationContext();
CharSequence titulo = "Nuevo Mensaje";
CharSequence descripcion = msg; // Aqui si muestra el mensaje correcto

Intent notIntent = new Intent(contexto,
MensajeActivity.class);

notIntent.putExtra("mensaje", msg);

PendingIntent contIntent = PendingIntent.getActivity(
contexto, 0, notIntent, 0);

notif.setLatestEventInfo(
contexto, titulo, descripcion, contIntent);

//AutoCancel: cuando se pulsa la notificaión ésta desaparece
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notif.defaults |= Notification.DEFAULT_VIBRATE;

//Enviar notificación
notManager.notify(1, notif);
}

CODIGO NUEVA PANTALLA

public class MensajeActivity extends Activity{

private TextView mensaje;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mensaje);

mensaje = (TextView)findViewById(R.id.lblMensaje);

Bundle extras = getIntent().getExtras();
if(extras !=null)
{
mensaje.setText(extras.getString("mensaje")); //Aqui siempre muestra el primer mensaje recibido
}else{
mensaje.setText("vacio");
}
GcmActivity.disminuirNotificacion();
}

}

Otra duda es. ¿Como puedo poner un numero en el icono de la app cuando llege una notificacion?. Por ejemplo el icono de los sms, cuando llega un nuevo sms pone un numero indicando cuantos sms se han recivido

Gracias

Gracias  
Etiquetado en: