Android Question NullPointerException - BA.switchObjectToInt

dragonguy

Active Member
Licensed User
Longtime User
my customer report to me, some devices randomly facing this error.

B4X:
Dim p As Phone
Dim status As Int = p.GetRingerMode

B4X:
Exception java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
anywheresoftware.b4a.BA.switchObjectToInt (BA.java:741)
com.probitto.my.hs.service1._service_start (service1.java:539)
java.lang.reflect.Method.invoke (Method.java)
anywheresoftware.b4a.BA.raiseEvent2 (BA.java:186)
anywheresoftware.b4a.BA.raiseEvent (BA.java:166)
com.probitto.my.hs.service1.handleStart (service1.java:121)
com.probitto.my.hs.service1.access$000 (service1.java:24)
com.probitto.my.hs.service1$1.run (service1.java:86)
anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:105)
com.probitto.my.hs.service1.onStartCommand (service1.java:84)
android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3014)
android.app.ActivityThread.-wrap17 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1442)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5421)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)

i test at debug and release mode, didn't facing this error.

anyone can help me look for it, which part cause the bugs?
 
Last edited:

dragonguy

Active Member
Licensed User
Longtime User
this is my service_start code
B4X:
Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
        Log("sms received")
        Dim p As Phone
        Dim status As Int = p.GetRingerMode
        sms_analize(status)
    else If StartingIntent.Action = "android.intent.action.PHONE_STATE" Then
        Log(StartingIntent.GetExtra("state"))
        Select StartingIntent.GetExtra("state")
            Case "IDLE"
                NativeMe.RunMethod("stop",Null)
                reset_flash_status
            Case "OFFHOOK"
                NativeMe.RunMethod("stop",Null)
                reset_flash_status
            Case "RINGING"
                Dim p As Phone
                Dim status As Int = p.GetRingerMode
                call_analize(status)
        End Select   
    End If
End Sub
 
Upvote 0
Top