Android Question crash report

ilan

Expert
Licensed User
Longtime User
what could be the reason for that crash? i have 184 crashes with the same crash log:

Jul 6, 6:41 PM on app version 43
hero2lte, Android 8.0
Report 21
java.lang.RuntimeException
:
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3696)
at android.app.ActivityThread.-wrap21 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1801)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6944)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)
at android.app.ContextImpl.startService (ContextImpl.java:1484)
at android.content.ContextWrapper.startService (ContextWrapper.java:663)
at anywheresoftware.b4a.keywords.Common.StartService (Common.java:894)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:211)
at www.sagital.mysalarynew.firebasemessaging.onStartCommand (firebasemessaging.java:69)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3679)
 

ilan

Expert
Licensed User
Longtime User
Which version of B4A are you using?

i always use the latest b4a version. i guess it was 1 version before 9.3

Are you doing anything special with background services? Sticky services? Scheduled services?

i have 2 services, 1 Starter, 1 Firebase


B4X:
'FirebaseMessaging
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals   
   Private fm As FirebaseMessaging
   Private Thread1 As Thread 'ignore
End Sub

Sub Service_Create
   fm.Initialize("fm")
   Thread1.Initialise("Thread1")
End Sub

Public Sub SubscribeToTopics
    Try
        If Starter.sendNotifaction Then fm.SubscribeToTopic("mysalarynew") 'you can subscribe to more topics
        fm.SubscribeToTopic("mysalarynewversion")
        Log("subscribed to topics")
    Catch
        Log(LastException)
    End Try
End Sub

Sub Service_Start (StartingIntent As Intent)
   If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
   Sleep(0)
   Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    
    Try
        Dim title As String
        title = Message.GetData.Get("title")
        title = title.Replace(" ","")
        If title = "promo" Then
            Dim str() As String = Regex.Split("\|",Message.GetData.Get("body"))
            Starter.promolink = str(2) 
            Dim n As Notification
            n.Initialize
            n.AutoCancel = True
            n.Light = True
            n.Sound = False
            n.Vibrate = True
            n.Icon = "icon"           
            n.SetInfo(str(0), str(1), openlink)
            n.Notify(1)   
        else if title.Contains("newversion") Then 'new version
           Starter.promolink = "https://play.google.com/store/apps/details?id=www.sagital.mysalarynew"
           Dim n As Notification
           n.Initialize
           n.AutoCancel = True
           n.Light = True
           n.Sound = False
           n.Vibrate = True           
           n.Icon = "icon"
           n.SetInfo("יצא עדכון חדש לשכרניק", "יצא עדכון חדש, מומלץ לעדכן את שכרניק!", openlink)
           n.Notify(1)   
         else if title.Contains("unsubscribe") Then 'new version
             Log("call unsubsribe to all topics")
             removeToken
        Else
           Dim n As Notification
           n.Initialize
           n.AutoCancel = True
           n.Light = True
           n.Sound = False
           n.Vibrate = True           
           n.Icon = "icon"
           n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
           n.Notify(1)               
        End If       
    Catch
        Log(LastException)
    End Try
End Sub

Sub Service_Destroy

End Sub

Public Sub removeToken
    Dim args(0) As Object
    Thread1.Name = "B4A Thread 1"
    Thread1.Start(Null, "ThreadSub1", args)
End Sub

Sub ThreadSub1 'ignore
    Dim jo As JavaObject
    Try
        jo = jo.InitializeStatic("com.google.firebase.iid.FirebaseInstanceId").RunMethod("getInstance", Null)
        jo.RunMethod("deleteInstanceId", Null)
    Catch
        Log(LastException)
    End Try
End Sub

Sub Thread1_Ended(fail As Boolean, error As String) 'An error or Exception has occurred in the Thread
    If Not(fail) Then
        Log ($"Thread1 Ended with error : ${error}"$)
    Else
        Log ("Thread1 Ended without error")
        Sleep(1000)
        SubscribeToTopics
    End If
End Sub
 
Upvote 0

Similar Threads

Top