AndreyPozdnyakov
Member
Hello!
I noticed one curious thing about the MyLocation type of application.
It started with the fact that I decided to write an application that runs in the background like MyLocation.
Let's say we have the following lines in a test program.
1. Module "Main".
2. Module "Starter"
3. Module "Tracker"
It really works stably if in the "Starter" module:
But, if we indicate here:
then when the device is restarted, the application no longer works: the timer in the "Tracker" module does not work!
But I have a question: after all, the "Starter" service should ALWAYS start when the device is rebooted?
Or it turns out here that if both services - "Stater" and "Tracker" - indicate
then "Starter" really starts, but there are no executable commands in it, and the launch of "Tracker" is ignored?
At the same time, if you specify in the "Starter" module:
then in this case the "Tracker" module is actually launched and the timer is triggered.
Is this so, please explain!
Very grateful in advance.
I noticed one curious thing about the MyLocation type of application.
It started with the fact that I decided to write an application that runs in the background like MyLocation.
Let's say we have the following lines in a test program.
1. Module "Main".
Main:
Sub Activity_Resume
StartService (Tracker)
End Sub
2. Module "Starter"
Starter:
#Region Service Attributes
#StartAtBoot: False
#End Region
3. Module "Tracker"
Tracker:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Private lock As PhoneWakeState
Private mp As MediaPlayer
Private Timer_Alarm As Timer
End Sub
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
lock.PartialLock
Timer_Alarm.Initialize ("Timer_Alarm", 10000)
Timer_Alarm.Enabled = True
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StartForeground (nid, CreateNotification ("..."))
End Sub
Sub Timer_Alarm_Tick
If Not (mp.IsInitialized) Then
mp.Initialize ()
End If
mp.Load (File.DirAssets, "sound.mp3")
mp.Play
End Sub
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2 (notification.IMPORTANCE_LOW)
notification.Icon = "icon"
notification.SetInfo ("Hello!", Body, Main)
Return notification
End Sub
It really works stably if in the "Starter" module:
B4X:
#StartAtBoot: False
But, if we indicate here:
B4X:
#StartAtBoot: True
then when the device is restarted, the application no longer works: the timer in the "Tracker" module does not work!
But I have a question: after all, the "Starter" service should ALWAYS start when the device is rebooted?
Or it turns out here that if both services - "Stater" and "Tracker" - indicate
B4X:
#StartAtBoot: True
then "Starter" really starts, but there are no executable commands in it, and the launch of "Tracker" is ignored?
At the same time, if you specify in the "Starter" module:
B4X:
#StartAtBoot: False
then in this case the "Tracker" module is actually launched and the timer is triggered.
Is this so, please explain!
Very grateful in advance.