skip to Main Content

I have created a android local notification using NotificationCompat.Builder, having two action "Accept" and "Reject", but after showing notification it hides after few seconds at top of display.

I want to keep that notification on the screen until user click on any action.

I am using

mBuilder.SetContentTitle(title)
                        .SetSound(sound)
                        **.SetAutoCancel(false)**

After setting SetAutoCancel as false still its disappears after few seconds.

How to hold that notification until user click on any action wither Accept or Reject? and how to play sound until any action taken from user?

2

Answers


  1. If you want to show your notification until user makes some action on it you should research topic about full screen intent. It regular heads-up notification but it exists until user make some action. Flow like a viber/telegram/whatsapp call with two buttons "Decline" and "Answer".

    This is the only way to hold your notififcation on the screen. But Google play store has new limitations

    My experience was a disaster I lost a few applications by these workaround with full screen intent. But if your application is "that provide calling and alarms only" you can try this approach.

    Login or Signup to reply.
  2. You can try to use the setOngoing(boolean) method. Such as:

    mBuilder.SetContentTitle(title)
                            .SetSound(sound)
                            .SetAutoCancel(false)
                            .SetOnGoing(true);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search