2011-06-30 13 views
5

Tengo una notificación de creación cuando se inicia el servicio pero no tengo idea de cómo cerrar esa notificación cuando el servicio se detiene o se destruye. tener alguna ideaClose android Notification

código siguiente que inicia la notificación cuando se inicia el servicio.

String ns = Context.NOTIFICATION_SERVICE; 
    final int KEEPUS_NOTIFICATION_ID = 1; 
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); 
    Notification notification = new Notification(R.drawable.notification_icon1, ticker_text, System.currentTimeMillis()); 
    Intent notificationIntent = new Intent(context, KeepusActivity.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 
    notification.setLatestEventInfo(context, ticker_content_title, ticker_content_text,contentIntent); 
    mNotificationManager.notify(KEEPUS_NOTIFICATION_ID, notification); 

Respuesta

21

uso gestor de notificaciones #cancel con su identificador de notificación

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
mNotificationManager.cancel(KEEPUS_NOTIFICATION_ID);