when use Activity_WindowFocusChanged with SDK 34 i get these error
B4X:
showexam_activity_windowfocuschanged (java line: 609)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA students.one.onlineexam.showexam.activityBA' on a null object reference in method 'java.lang.String students.one.onlineexam.showexam._activity_windowfocuschanged(boolean)'
at students.one.onlineexam.showexam._activity_windowfocuschanged(showexam.java:609)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at students.one.onlineexam.showexam.onWindowFocusChanged(showexam.java:191)
at androidx.appcompat.view.WindowCallbackWrapper.onWindowFocusChanged(WindowCallbackWrapper.java:125)
at com.android.internal.policy.DecorView.onWindowFocusChanged(DecorView.java:1789)
at android.view.View.dispatchWindowFocusChanged(View.java:15277)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:1508)
at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:3690)
at android.view.ViewRootImpl.-$$Nest$mhandleWindowFocusChanged(Unknown Source:0)
at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:5538)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5452)
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:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I'm guessing you're not using B4XPages. Generally that event is weird since the activity can be "paused" when it's raised, meaning you can't really do anything.
You can try the code B4XPages is using, maybe it will help. Otherwise I'd suggest avoiding that event.
B4X:
Dim module As JavaObject
module.InitializeStatic(jo.RunMethodJO("getActivityBA", Null).GetField("className")).SetField("dontPause", True)