I am displaying an icon in status bar.Now I want to remove that icon immediately when I open that content, after some time if we receive any alert, that icon will be display
Intent resultIntent = new Intent(application, MainActivity.class);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent resultPendingIntent = PendingIntent.getActivity(application, 0, resultIntent, 0);
NotificationManager nmgr = (NotificationManager) application.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(application)
.setSmallIcon(R.drawable.icon_battery)
.setContentTitle(application.getString(R.string.app_name))
.setContentText("your text")
.setOnlyAlertOnce(false)
.setAutoCancel(true)
.setTicker("your ticker")
.setDefaults(Notification.DEFAULT_SOUND ) //| Notification.DEFAULT_VIBRATE
.setContentIntent(resultPendingIntent)
.setVisibility(VISIBILITY_SECRET)
.setPriority(Notification.PRIORITY_MIN);
Notification mNotification = mBuilder.build();
// mNotification.flags |= FLAG_NO_CLEAR;
nmgr.notify(0, mNotification);