Android Question Dismissing a notification prevents next few notifications from being displayed

CaptKronos

Active Member
Licensed User
Longtime User
Running the following code produces a notification every 10s and works as expected until I manually dismiss a notification by swiping a notification up. Notifications are then no longer displayed for about one minute. The notifications are still being generated and the notification sounds can still be heard. After the one minute the notifications start appearing again. I have tried this on two different phones with exactly the same behaviour including the same one minute period. I am wondering if this is a standard Android function that I have never noticed before though I couldn't find it via Googling.

B4X:
Sub Process_Globals
    Private notiTimer As Timer, notiCount As Int=0
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    notiTimer.Initialize("notiTimer", 10000)
    notiTimer.Enabled=True
End Sub

Sub notiTimer_Tick
    Log("noti " & "#" & notiCount)
    HighPriority_Notification("Hello" , "#" & notiCount)
    notiCount=notiCount+1
End Sub

Sub HighPriority_Notification(title As String, content As String)
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "HIGH").smallIcon(LoadBitmapResize(File.DirAssets, "smiley.png", 24dip, 24dip, False))
    n.Build(title, content, "tag", Me).Notify(1)
End Sub
 

Marvel

Active Member
Licensed User
Running the following code produces a notification every 10s and works as expected until I manually dismiss a notification by swiping a notification up. Notifications are then no longer displayed for about one minute. The notifications are still being generated and the notification sounds can still be heard. After the one minute the notifications start appearing again. I have tried this on two different phones with exactly the same behaviour including the same one minute period. I am wondering if this is a standard Android function that I have never noticed before though I couldn't find it via Googling.

B4X:
Sub Process_Globals
    Private notiTimer As Timer, notiCount As Int=0
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    notiTimer.Initialize("notiTimer", 10000)
    notiTimer.Enabled=True
End Sub

Sub notiTimer_Tick
    Log("noti " & "#" & notiCount)
    HighPriority_Notification("Hello" , "#" & notiCount)
    notiCount=notiCount+1
End Sub

Sub HighPriority_Notification(title As String, content As String)
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "HIGH").smallIcon(LoadBitmapResize(File.DirAssets, "smiley.png", 24dip, 24dip, False))
    n.Build(title, content, "tag", Me).Notify(1)
End Sub
Why are you displaying a notification every 10s? You should use an ongoing notification for that and just update the notification with timer.
 
Upvote 0

CaptKronos

Active Member
Licensed User
Longtime User
This isn't meant to be a real-world scenario but rather a small amount of code that demonstrates this weird (at least to me it's weird) phenomenon that I have spotted. I could imagine something similar happening if the OS thought it was being spammed with notifications but this isn't what's happening. The notifications only stop being displayed when the user swipes up a notification. Swiping left or right has the usual effect of removing the notification and the next notification gets displayed 10s later.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Android 10 has added more energy options. See here: https://developer.android.com/topic/performance/power/power-details

Check your app's settings (on a real device!). Go to "options -> messages" (menu may be different), search for your app and check the settings. Search for WhatsApp, too (to see the different options of another app).
 
Upvote 0

CaptKronos

Active Member
Licensed User
Longtime User
Thanks both. Not that it matters now that I know it is standard behaviour and not a problem with my code, but what is the point of this "no notifications for one minute" feature? Is it just to allow users to indicate that they don't want to be spammed for the next minute?
Because notifications slide down from the top, my natural gesture to dismiss them is to swipe them back up. Then because notifications stopped appearing I was telling myself that the whole notification system was really flaky!
 
Last edited:
Upvote 0
Top