How can I show my notification for Android before closing my application?

I have been developing for Android for a while, but this is my first shot in notifications. I have a notification setting, as described in the Android SDK tutorial, but I can’t figure out how to save the notification until my application is closed. I want to disable this little minus sign at the end of the notification. I do not want my notification to disappear when the user clicks on it. I think there will be a notification flag ... but I can't figure it out. I am developing an Android SDK 2.2. I know this is a simple question, and I apologize if this answer is already here ... I could not find exactly what I was looking for.

// Create notification manager String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); Notification notification = new Notification(R.drawable.ic_launcher, "Ready", System.currentTimeMillis()); Intent notificationIntent = new Intent(this, HomeActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); // Make a notification notification.setLatestEventInfo(getApplicationContext(), "Ready", "Select to manage your settings", contentIntent); mNotificationManager.notify(0, notification); 
+4
source share
1 answer

You want FLAG_ONGOING_EVENT . Also try deleting FLAG_NO_CLEAR and FLAG_AUTO_CANCEL if they are part of the default values.

+5
source

Source: https://habr.com/ru/post/1391364/


All Articles