Hi there...
well.. I understand that sometimes, some SDK works different... but many times developers ignore some things...but this is a custom app for a client that works with Google Play so I must be into limits of Errors. I hope get help for those.
As i understand the problem coming from Services (the following errors sendxml, searchbtn, sendit fixed)
So... the "bigger" problems i think are the following:
[1]
xxxxxxxxx.starter.handleStart
java.lang.RuntimeException
May be because i don't have starter service... do i need it ? I thought that we must not use starter service. do i need just have it in my code and never use it ? - or what ?
However if not needed - I am not calling it anywhere... why having this error?
[2]
android.app.ActivityThread.generateForegroundServiceDidNotStopInTimeException
android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException
at my service have those:
Is it something that i can do for stopping the service at the specific time and auto start it - to continue my work ?
well.. I understand that sometimes, some SDK works different... but many times developers ignore some things...but this is a custom app for a client that works with Google Play so I must be into limits of Errors. I hope get help for those.
As i understand the problem coming from Services (the following errors sendxml, searchbtn, sendit fixed)
So... the "bigger" problems i think are the following:
[1]
xxxxxxxxx.starter.handleStart
java.lang.RuntimeException
May be because i don't have starter service... do i need it ? I thought that we must not use starter service. do i need just have it in my code and never use it ? - or what ?
However if not needed - I am not calling it anywhere... why having this error?
[2]
android.app.ActivityThread.generateForegroundServiceDidNotStopInTimeException
android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException
at my service have those:
B4X:
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
If Provider.IsInitialized=False Then Provider.Initialize
xtimer.Initialize("xtimer",20000)
If Main.secureit=True Then
mytimer.Initialize("mytimer",5000)
End If
End Sub
Sub Service_Start (StartingIntent As Intent)
If onlyonetime=0 Then
StartForegroundWithType("...")
n.Initialize("default", Application.LabelName, "LOW").AutoCancel(True).SmallIcon(LoadBitmap(File.DirAssets,"icon4app.png"))'.LargeIcon(LoadBitmap(File.DirAssets,"icon2.png"))
n.Build("xxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "tag1", Main).Notify(1)
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
xtimer.Enabled=True
If Main.secureit=True Then
mytimer.Enabled=True
End If
End If
onlyonetime=1
End Sub
Sub StartForegroundWithType(notif As Notification)
Dim oContext As JavaObject
Dim serviceType As Int = 1
Dim RunningPhone As Phone
oContext.InitializeContext
If RunningPhone.SdkVersion >= 29 Then
Try
oContext.RunMethod("startForeground", Array As Object(1, CreateNotification(notif), serviceType))
Catch
Log(LastException)
Service.StartForeground(1, notif)
End Try
Else
Service.StartForeground(1, CreateNotification(notif))
End If
End Sub
Sub delayedstops
If Main.isexited=False Then
Main.isexited=True
xtimer.Enabled = False
mytimer.Enabled = False
ToastMessageShow("my app will close...",True)
' Stop manual foreground mode (and remove the notification)
Service.StopForeground(1)
Sleep(500)
' Cancel any future scheduled starts
CancelScheduledService(Me)
Sleep(500)
CallSubDelayed2(Main, "ServiceStopped", "myService")
End If
End Sub
Sub Service_Destroy
If Main.isexited=False Then CallSubDelayed(Me,"delayedstops")
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return False
End Sub
Private Sub Service_Timeout(Params As Map)
Service.StopForeground(1)
End Sub
Is it something that i can do for stopping the service at the specific time and auto start it - to continue my work ?