Android Question immersive mode crush

yaniv hanya

Active Member
Licensed User
Hi
I use the immersiveMode (from thi tut)
After a few minutes of running, it crashes. I get this log
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Error occurred on line: 152 (Main)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA b4a.example.main.activityBA' on a null object reference
at b4a.example.main._activity_windowfocuschanged(main.java:515)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.onWindowFocusChanged(main.java:185)
at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:1451)
at android.view.View.dispatchWindowFocusChanged(View.java:10307)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1217)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:4018)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

linr 152 is the Activity_WindowFocusChanged event
B4X:
Sub Activity_WindowFocusChanged(HasFocus As Boolean) ' - line 152
    If HasFocus Then
        Try
            Dim jo As JavaObject = Activity
            Sleep(300)
            jo.RunMethod("setSystemUiVisibility", Array As Object(5894)) '3846 - non-sticky
        Catch
            'Log(LastException) 'This can cause another error
        End Try 'ignore       
    End If
End Sub
Do you have an idea why?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

This error will only happen in debug mode. It is related to the event being raised when a breakpoint is reached.
 
Upvote 0
Top