I've only seen examples of Service.StartForeground where the ID = 1. For example: Service.StartForeground(1,test). Is there something special about the 1? I own a tablet where I have to make the ID = 0 or it will error on the call.
I dont know id the 0 is allowed as an ID for the notification object (see docu of this object and the ID)
But if it is allowed then you can use a 0 too if you use the 0 in the definition of the notification object
Setting ID to 0 makes the Service.StartForeground just do nothing. What I'm finding is that I need to NOT set the Icon property for the call to work. I suspect this indicates some stupidity on my part. Any idea what I'm leaving out here?
Below is the service routine whose sole function is to keep the app from being killed. Every second it updates a clock in the activity.
B4X:
Sub Process_Globals
Dim Notification1 As Notification
Dim timer1 As Timer
End Sub
Sub Service_Create
Notification1.Initialize
'Notification1.Icon = "icon"
Service.StartForeground(1,Notification1)
timer1.Initialize("timer1",1000)
timer1.Enabled = True
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
timer1.Enabled = False
End Sub
Sub timer1_tick
CallSub(Main, "Clock")
End Sub
What is the purpose of this code? If the activity is visible then Android will not kill the process. If the activity is not visible then CallSub will not do anything.
Basically I want an app that keeps a display of some current information 24/7. I've tried putting a KeepAlive(True) in Activity_Resume, but once and a while I find that the phone/tablet is just sitting on the home page like the app had been killed. The solution was supposed to be a Service.StartForeground, but I'm not having luck getting that call to work.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.