I'm using below snippet to show a notification from a service inside my app:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(currentNotificaion.getMessageTitle())
.setContentIntent(contentIntent)
.setContentText(currentNotificaion.getMessageText())
.setAutoCancel(true);
int mNotificationId = (int) currentNotificaion.getMessageServerID();
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
My service is declared like this in manifest:
<service
android:name="com.myapp.services.NotificationService"
android:stopWithTask="false">
</service>
But when closing my app from recent apps list, notification is disappear and removed from notification bar. Another things is I'm not going to use stick notifications which are never removed from notification bar.
How can I avoid this?