Up til recently (i.e. Android 9)
#StartAtBoot: True
worked fine, but testing on Android 10 I couldn't get this to work.
Any ideas?
#StartAtBoot: True
worked fine, but testing on Android 10 I couldn't get this to work.
Any ideas?
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
'--- These global variables will be declared once when the application starts.
'--- These variables can be accessed from all modules.
Private tmrStart As Timer
End Sub
Sub Service_Create
'--- set timer to start app after 1 seconds
'--- this gives time for system to init other stuff
tmrStart.Initialize("tmrStart",15000)
End Sub
Sub Service_Start (StartingIntent As Intent)
'--- enabled timer
tmrStart.Enabled = True
End Sub
Private Sub Service_Destroy
End Sub
Sub tmrStart_Tick
tmrStart.Enabled = False
'--- if we find the file 'autoStart.dat' in the folder 'File.DirInternal'
'--- then auto start the app.
Dim checkFile As String = "autoStart.dat"
If File.Exists(Common.rp.GETsafeDirDefaultExternal(""),checkFile) Then
Common.SaveLog("Auto Start is enabled")
StartActivity(Main)
Else
Common.SaveLog("Auto Start is disabled")
End If
End Sub
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public CL As Crashlytics
Public rec As ScreenShotterContinuous
Private adm As ADM
End Sub
Sub Service_Create
Dim context As JavaObject 'depends on JavaObject
context.InitializeContext
CL.Initialize(context)
rec.Initialize("rec")
adm.Initialize("ADM")
End Sub
Sub Service_Start (StartingIntent As Intent)
Common.SaveLog("Service Started")
Sub Class_Globals
Private ion As Object
Private phone As Phone
End Sub
Public Sub Initialize
End Sub
Public Sub GetPermission As ResumableSub
If phone.SdkVersion >= 23 Then
Dim settings As JavaObject
settings.InitializeStatic("android.provider.Settings")
Dim ctxt As JavaObject
ctxt.InitializeContext
If settings.RunMethod("canDrawOverlays", Array(ctxt)) = True Then
Return True
End If
Dim i As Intent
i.Initialize("android.settings.action.MANAGE_OVERLAY_PERMISSION", "package:" & Application.PackageName)
StartActivityForResult(i)
Wait For ion_Event (MethodName As String, Args() As Object)
Return settings.RunMethod("canDrawOverlays", Array(ctxt))
Else
Return True
End If
End Sub
Private Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Private Sub GetBA As Object
Dim jo As JavaObject = Me
Return jo.RunMethod("getBA", Null)
End Sub
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
'--- These global variables will be declared once when the application starts.
'--- These variables can be accessed from all modules.
Private tmrStart As Timer
End Sub
Sub Service_Create
'--- set timer to start app after 1 seconds
'--- this gives time for system to init other stuff
tmrStart.Initialize("tmrStart",5000)
Common.SaveLog("Timer Initialized")
End Sub
Sub Service_Start (StartingIntent As Intent)
'--- enabled timer
tmrStart.Enabled = True
Common.SaveLog("Timer Started")
End Sub
Private Sub Service_Destroy
End Sub
Sub tmrStart_Tick
tmrStart.Enabled = False
Common.SaveLog("Timer Tick")
Dim c As RequestDrawOverPermission 'this is the name of the class
c.Initialize
Common.SaveLog("Requested")
Wait For (c.GetPermission) Complete (Success As Boolean)
Common.SaveLog("Permission: " & Success)
Common.SaveLog("Auto Starting")
StartActivity(Main)
End Sub
Dim c As RequestDrawOverPermission 'this is the name of the class
c.Initialize
Common.SaveLog("Requested")
Wait For (c.GetPermission) Complete (Success As Boolean)
Common.SaveLog("Permission: " & Success)
To Install Unknown AppsIs there any way to force this permission?