hi first i Do apologize for my bad english i have a service in my app that has this code #StartAtBoot: true but in one phone with android 4... after reboot the phone service run automatically but this service doesn't work with another phone with android 9 anybody know BRIEFLY say to me which code i should write in my service that run after reboot on two android models this code doesn't work for me on android 9
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
you used #StartAtBoot in other than starter service?
i remember in the starter service it had no effect.
in own service i had it working in android 8.1
the Notification indicate that the service is running
B4X:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Dim PhoneWakeState1 As PhoneWakeState
Dim PhoneEvents1 As PhoneEvents
End Sub
Sub Service_Start(StartingIntent As Intent)
Dim n As Notification
n.Initialize
n.Icon="icon"
n.Sound=False
n.Light = False
n.Vibrate = False
n.SetInfo("Alarm","Listening for a Alarm Message",Main)
Service.StartForeground(1,n)
PhoneWakeState1.PartialLock
PhoneEvents1.Initialize("PhoneEvents1")
End Sub
the Notification indicate that the service is running
B4X:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Dim PhoneWakeState1 As PhoneWakeState
Dim PhoneEvents1 As PhoneEvents
End Sub
Sub Service_Start(StartingIntent As Intent)
Dim n As Notification
n.Initialize
n.Icon="icon"
n.Sound=False
n.Light = False
n.Vibrate = False
n.SetInfo("Alarm","Listening for a Alarm Message",Main)
Service.StartForeground(1,n)
PhoneWakeState1.PartialLock
PhoneEvents1.Initialize("PhoneEvents1")
End Sub
Ok,my phone is Redmi note 7 that has a Permissions-->Autostart section in settings
when you turn app on in this section app start automatically after boot
i wonder some apps (third party app no system app) in my phone are off in Autostart section but run automatically
after reboot (though this app has widget on desktop)
i am not familiar with widget programing
wonder some apps (third party app no system app) in my phone are off in Autostart section but run automatically
after reboot (though this app has widget on desktop)
my app is a kind of reminder and should run if user reboots phone
i think have to design a wiget for my app for solving problem
i think this is for my phone https://c.mi.com/thread-2175984-1-0.html
Tank Erel and Markusr