Android Question Fatal Exception: android.app.RemoteServiceException

asales

Expert
Licensed User
Longtime User
I get this error in Firebase Crashlytics, in some types of devices, like Itel A60, Tecno POP 7, TCL 10 SE:
Fatal Exception: android.app.RemoteServiceException:
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{c020b05 u0 br.com.apps.profileapp/.firebasemessaging}


Is a B4XPages app and I use the original code from Firebase Push Notifications 2023+.

I check this thread Automatic Foreground Mode and it uses this code to Service_Start:
B4X:
Sub Service_Start (StartingIntent As Intent)
   fm.HandleIntent(StartingIntent)
   Sleep(0) 'allow the MessageReceived event to be raised.
   Service.StopAutomaticForeground
End Sub
Can I use the same approach ("new code") to Receiver_Receive? Could be a soluction?
B4X:
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    'original code
    If FirstTime Then
        fm.Initialize("fm")
    End If
    fm.HandleIntent(StartingIntent)

   'new code
   Sleep(0)
   Service.StopAutomaticForeground
End Sub


Thanks in advance for any tips.
 

asales

Expert
Licensed User
Longtime User
Is this the full error message? If not please post it.
Here the full error message to 2 apps that uses the FirebaseMessaging receiver.
As I said, this is happens in some types of devices: Tecno POP 7, Itel S18, Itel A60, Camon 19, Nokia 6.2.
B4X:
Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{6b7980c u0 br.com.apps.profileapp/.firebasemessaging}
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2006)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7701)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
B4X:
Fatal Exception: android.app.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{d880e58 u0 br.com.apps.stickerapp/.firebasemessaging}
at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1989)
at android.app.ActivityThread.access$2700(ActivityThread.java:272)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2214)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7981)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
 
Upvote 0
Top