Android Question can check if IsInitialized DSNavigationDrawer ?

scsjc

Well-Known Member
Licensed User
How can I know if DSNavigationDrawer is in isinitialize, because in the "Activity_Keypress" I check if it is open before leaving ....
i use on this part of code before close activity:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
   If KeyCode = KeyCodes.KEYCODE_BACK Then
       If NavDrawer.IsDrawerOpen Then
           NavDrawer.CloseDrawers
           Return True
       End If
       Activity.finish
End Sub
sometimes this error occurs:
B4X:
java.lang.NullPointerException:
at de.amberhome.objects.NavigationDrawerWrapper.IsDrawerOpen (NavigationDrawerWrapper.java:332)
at com.oficinadirecta.main._activity_keypress (main.java:539)
at java.lang.reflect.Method.invoke (Native Method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:196)
at com.oficinadirecta.main$HandleKeyDelayed.runDirectly (main.java:230)
at com.oficinadirecta.main$HandleKeyDelayed.run (main.java:227)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6702)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:911)
I think it is because it is not initialized, can it be checked?
Is there another better way to do it?
thanks
 
Top