A service which starts at bootup with "#StartAtBoot: True" isn't working on Android 7.1.2. It works fine on version 4-6.
I created a new app & service with nothing but a toast message when the service starts. It's not starting on boot up. Can you see what is wrong?
I'm using B4A 9.5.
I've attached the app source zip but here is the code too:
Main Activity
Starter Service
TestService Service
Manifest
I created a new app & service with nothing but a toast message when the service starts. It's not starting on boot up. Can you see what is wrong?
I'm using B4A 9.5.
I've attached the app source zip but here is the code too:
Main Activity
B4X:
#Region Project Attributes
#ApplicationLabel: Service Test
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
StartService(TestService)
Activity.Finish
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Starter Service
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Sub Service_TaskRemoved
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
TestService Service
B4X:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
End Sub
Sub Service_Create
ToastMessageShow("Service_Create", True)
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
End Sub
Manifest
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)