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.
 
Top