Android Question calling notifcation from service

Addo

Well-Known Member
Licensed User
i am trying to create a notifcation when service started i am using b4a version 8 and i have follow the instruction to set info at last call like following

B4X:
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.

    
    nNotify.Initialize
    nNotify.Icon = "icon"
    nNotify.Sound=False
    nNotify.Vibrate=False
    nNotify.Light=False
    nNotify.OnGoingEvent=True
    nNotify.SetInfo("back to app", "Test", Main2)
    Service.StartForeground(1, nNotify)
   

End Sub

but this crash on android 5.1 each time service started

thats how i start the service on main2 activity create

B4X:
StartService(Service)

what i am doing wrong ?
 

Addo

Well-Known Member
Licensed User
very weird i have tried but no toast message exception when the app stopped from working message

B4X:
    Try
    
    nNotify.Initialize
    nNotify.OnGoingEvent=True
    nNotify.Sound=False
    nNotify.Vibrate=False
    nNotify.Light=False
    nNotify.Icon = "icon"
    nNotify.SetInfo("Test", "test", Main)

    Service.StartForeground(9999898, nNotify)
    
    Catch
    ToastMessageShow(LastException, True)
    End Try
 
Upvote 0

Addo

Well-Known Member
Licensed User
Also I notice if I comment out the icon the app works without crash
B4X:
Try
    
    nNotify.Initialize
    nNotify.OnGoingEvent=True
    nNotify.Sound=False
    nNotify.Vibrate=False
    nNotify.Light=False
    'nNotify.Icon = "icon"
    nNotify.SetInfo("Test", "test", Main)

    Service.StartForeground(9999898, nNotify)
    
    Catch
    ToastMessageShow(LastException, True)
    End Try

What could be the problem with icon is it need to be under setinfo ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can add firebase crashlytics library, let the app crash at the customers device and check the Crashlytics crashreport in the Firebaseconsole later.
 
Upvote 0

Addo

Well-Known Member
Licensed User
i will wait 24 hours until my firebase start capture also i notice on some old phones the icon of notifcation is not visible and have blue circle instead the sie of the icon is 36 its not that big also i have created drawable Resolution to capture the icon based on the phone Resolution

i have created

drawable-hdpi
drawable-ldpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi

and make them read only to make it android friendly but the blue circle in older device is weird
 
Upvote 0

Addo

Well-Known Member
Licensed User

Attachments

  • testnotify.zip
    5.2 KB · Views: 199
  • Screenshot_2018-04-12-15-43-23.png
    Screenshot_2018-04-12-15-43-23.png
    62.1 KB · Views: 180
Last edited:
Upvote 0

Addo

Well-Known Member
Licensed User
I have read on google similar issues I came up with this but this is oreo certain not sure if its similar case for android 5 devices

https://stackoverflow.com/questions/47368187/android-oreo-notification-crashes-system-ui

Honestly did not find any work around for this issue only I had to detect the running api and not load the notification for the api that got this notification crash problem

Hope experts who stuck with similar issue to help with a better solution if there any solution for it
 
Upvote 0
Top