Rishi
Rishi

Reputation: 151

Android: How to make notification visible even after app is cleared from memory

I want to make a notification which cannot be cancelled by the user manually, just like google navigation notification. I don't know how to do it. Please Help.

Below is my code that I had tried.

 mBuilder.setSmallIcon(R.mipmap.ic_launcher)
       .setOngoing(true)
       .setContentIntent(pendIntent)
       .setContent(mRemoteViews)
       .setPriority(0) 
       .setTicker(ticker);

Thanks.

Upvotes: 0

Views: 195

Answers (1)

Sam
Sam

Reputation: 5392

Try adding this

mBuilder.setOngoing(true)

Other option is to use intentService or background service to make your notification for you instead of the application context.

Upvotes: 1

Related Questions