Android Question Notification does not disappear and remains permanently in place

Pascal Hamm

Member
Licensed User
Hello together,
I have a very strange problem with notifications in my app for some time now.
It happens that after one or two days of continuous use of the app, a second notification appears, which cannot be clicked away.
Only after a restart of the phone everything is normal again.

For your information:
I automatically send traffic jam notifications to my app every 10 minutes. These also arrive without problems and the notification also disappears as soon as you click on it or remove it.

After one or two days a second notification appears, which only contains the app name and nothing else.
It seems that this notification also appears briefly in the phone as soon as another notification is received. So to speak as an indicator that something is happening in the background. At some point, however, this remains permanently there and no longer goes away.

I have already removed many places in the code to find the error, but without success.
It seems that this only happens with Xiamio smartphones under MIUI.

Has anyone else had the same problem and solved it?

Smartphone: Mi Note 10 Lite
MIUI Global: 12.5.5
B4A Version: 11

Thank you very much for your help!

Here is my code and two screenshots:


FirebaseMessaging:
#Region  Service Attributes
    #StartAtBoot: False
   
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
End Sub

Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
   
    Log("-------------------Message arrived-------------------")
   
    DateTime.DateFormat="hh:mm:ss"

    Log("Datum/Uhrtzeit: " & DateTime.Date(DateTime.now))
    Log($"Message data: ${Message.GetData}"$)
                   
                '---------------------------------------------------------------
                '---------------------------------------------------------------
               
                Dim no As NB6
                Dim AppIcon As Bitmap
                AppIcon.Initialize(File.DirAssets, "icon_staumelder_app_notification_24x24.bmp")
               
                       
                no.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(AppIcon)
                no.Build("Message arrived", "TEXT TEXT TEXT", "tag1", Main).Notify(1) 'It will be Main (or any other activity) instead of Me if called from a service.
               
               
                '---------------------------------------------------------------
                '---------------------------------------------------------------
           

End Sub

Sub Service_Destroy

End Sub
 

Attachments

  • IMG_1665.JPG
    IMG_1665.JPG
    226.8 KB · Views: 146
  • IMG_1666.JPG
    IMG_1666.JPG
    214.4 KB · Views: 130

toby

Well-Known Member
Licensed User
Longtime User
MIUI is not Android, and you've got what you've paid for. Stay with Android if you don't want to open a can of worms.
 
Upvote 0

Num3

Active Member
Licensed User
Longtime User
I had this problem a while back.
I traced it to the fact the APP crashed because i was starting the "Starter" service from boot (copy / paste error šŸ§ ), instead of:

B4X:
#Region  Service Attributes
    'Do not start the Starter at boot, it will crash it, use another service for boot startup
    #StartAtBoot: False          
    #ExcludeFromLibrary: True
#End Region
 
Upvote 0

Marvel

Active Member
Licensed User
MIUI is not Android, and you've got what you've paid for. Stay with Android if you don't want to open a can of worms.
Well, it will be difficult to explain to all users of your app why they should not use MIUI. By the way, it's android.
 
Upvote 0

Pascal Hamm

Member
Licensed User
Hello together,

thanks for the useful infos.
I have now tried a few more things, but still could not fix the error.
The error also just seems to come sporadically at some point.

This is really very annoying that it only occurs on MIUI devices.

Does anyone else have any good ideas?
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Unfortunately, I cannot delete the notification at all. Not by swiping, nor by pressing on it.
I use the firebasemessaging - with the code like yours - and works fine in my Xiaomi 9A.

Please, create an small project (with the problem) and put it here.

Others users, that have an Xiaomi, can test and give you a better feedback.
 
Upvote 0

Pascal Hamm

Member
Licensed User
I use the firebasemessaging - with the code like yours - and works fine in my Xiaomi 9A.

Please, create an small project (with the problem) and put it here.

Others users, that have an Xiaomi, can test and give you a better feedback.
That's a good idea, I'll create a small project about it in the days.
 
Upvote 0
Top