Android Question Notification causes error

Carlo2015

Member
Licensed User
Longtime User
Please help guys. I dont know why but the code below wont run on other phones but runs perfectly well on my asus zenfone 2.

B4X:
Sub Process_Globals
Dim myNotification As Notification
End Sub

B4X:
Sub Service_Create
myNotification.Initialize
    myNotification.Icon = "logo"
    myNotification.Sound = False
    myNotification.Vibrate = False
    myNotification.SetInfo("Title", "Message",Main)
    myNotification.Notify(10000)

B4X:
Sub Service_Start (StartingIntent As Intent)  
    Service.StartForeground(10000, myNotification)
End Sub

When omitted the app runs well on 2 other phones (Vivo and SOny Experia). I need the app to NOT die when installed as this is a GPS app that updates coordinates every 10 mins.

B4X:
#StartCommandReturnValue: android.app.Service.START_STICKY


does not work. when the phone locks the service stops.

EDIT: this are my libs

10o37t5.png
 
Last edited:

Carlo2015

Member
Licensed User
Longtime User
hi erel,

thanks for the reply.

i change the whoel code to just

Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS

on service_create and it worked well now. sorry for the late update as i tested it yet before confirming it here. it took me 1 hour to test. had the phone locked for the whole duration and it still sends update.

thanks
 
Upvote 0
Top