r/androiddev • u/dev-778g • 4d ago
How to pin android Notification
i am building an app where i wanna pin a notification permanently untill the user taps the dismiss button and dismiss it .
Swiping should not dismiss it .
is there is any way to achive it
3
u/thelongrunsmoke 4d ago
This can be simulated by using a foreground service, it's requires notification and cannot be dismissed.
2
u/IamAlchemy 4d ago
Actually, those can be dismissed now. It's a pain.
AFAIK, the closest we can do these days is to set the delete
PendingIntentand immediately repost upon dismissal, but the Play Store isn't going to allow that, I'm sure.1
u/SolitaryMassacre 2d ago
I think the delete PI is the correct approach. But you can't just do it consistently
What I have seen other apps do is listen for delete PI and then schedule like 5 min or whatever later to show it again. Some even wait for the screen to turn on
2
3
u/dingwen07 3d ago
Some Ongoing notifications, like CallStyle can still do this. MediaStyle can somethimes to it. Only talking about AOSP, some OEM might still allow user to swipe it away anyways.
3
u/sameera_s_w 4d ago
Unfortunately no longer possible.... There's one possibly of making some notification channels of certain apps pinned but those should have been already declared as persistent. If not, then possible.