Android Question starter.handleStart RuntimeException

giggetto71

Active Member
Licensed User
Longtime User
I am posting a Runtime exception from the google console. apparently it is complaining about the service type missing in the foreground call.
anything I can do on my side?

Exception java.lang.RuntimeException:
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5286)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2531)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
Caused by java.lang.RuntimeException:
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent (ServiceHelper.java:173)
at gigiosoft.MQTTAlert.starter.handleStart (starter.java:102)
at gigiosoft.MQTTAlert.starter.access$000 (starter.java:8)
at gigiosoft.MQTTAlert.starter$1.run (starter.java:74)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:240)
at gigiosoft.MQTTAlert.starter.onStartCommand (starter.java:72)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5268)
Caused by android.app.MissingForegroundServiceTypeException:
at android.app.MissingForegroundServiceTypeException$1.createFromParcel (MissingForegroundServiceTypeException.java:53)
at android.app.MissingForegroundServiceTypeException$1.createFromParcel (MissingForegroundServiceTypeException.java:49)
at android.os.Parcel.readParcelableInternal (Parcel.java:4904)
at android.os.Parcel.readParcelable (Parcel.java:4886)
at android.os.Parcel.createExceptionOrNull (Parcel.java:3086)
at android.os.Parcel.createException (Parcel.java:3075)
at android.os.Parcel.readException (Parcel.java:3058)
at android.os.Parcel.readException (Parcel.java:3000)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:7234)
at android.app.Service.startForeground (Service.java:775)
at anywheresoftware.b4a.objects.ServiceHelper.StartForeground (ServiceHelper.java:85)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.handleStartIntent (ServiceHelper.java:171)


I had a similar issue for my service where I replaced the StartForeground with:

B4X:
Sub StartForegroundWithType(notif As Notification)
    Dim oContext As JavaObject
    Dim serviceType As Int = 16  ' connectedDevice like in the manifest
    
    Dim RunningPhone As Phone
    
    oContext.InitializeContext
    
    If RunningPhone.SdkVersion >= 29 Then
          
        Try
           oContext.RunMethod("startForeground", Array As Object(1, notif, serviceType))                 
        Catch
           Log(LastException)
           Service.StartForeground(1, notif)
        End Try   
    Else
        Service.StartForeground(1, notif)
    End If
End Sub

but I don't think I can change the starter service.
thanks for your support as usual.
 

giggetto71

Active Member
Licensed User
Longtime User
ok. sorry for the confusion..the code provided is for my service, Not for the starter. for the starter I did not touch the service_create or the service_start.
I was just saying that I had a similar issue (missing service type) for my service as I was calling Service.StartForeground(1, Notification1). after replacing it with StrartForegroundWithType(Notification1) code above, I did not see any complain on google console.

this case is different as this runtimeexeception (attached above) seems to me about the starter service and I really don't do anything strange on it.
hope this clarifies a bit.
 
Upvote 0
Top