This works: IntentService with NotificationCompat.Builder providing a notification for use with NotificationManager.notify (). SetContentIntent (pendingIntent). When the notification is sent, the notification appears in the notification AND CONSTANT (remains alive until the user clicks on it, after which he starts the action specified in .setContentIntent). Good! What doesn't work: I would like the service to be as durable as a telephone service, so startForeground () would seem to be recommended. However, when I turn it on, the associated notification does appear in the tray as it should, but it is NOT STABLE and disappears when the IntentService ends (unlike above). (The associated notification also uses .setContentIntent and triggers another action.) Any suggestions? It is very important that the service does not die until it detects a specific (rare) event. It is also important that the notification remains alive until the user responds by clicking it!
Here is the summary code (last case): Thanks!
public class SService extends IntentService { public SService() { super("SService"); } @Override protected void onHandleIntent(Intent sIntent) {
}
source share