Android Question ACToolBarLight error under Android 4.x

peacemaker

Expert
Licensed User
Longtime User
HI, All

Using AppCompat (v.3.52) toolbar in B4A 8.0, compiling by android27.jar, Google repository is up to date.
Under Android 6+ all is OK.

But i have found that under Android 4.2 and 4.4 app has the java.lang.NullPointerException error in the line:
B4X:
Sub Activity_CreateMenu(Menu As ACMenu)

B4X:
** Activity (main) Pause, UserClosed = true **
Error occurred on line: 268 (Main)
java.lang.NullPointerException
    at peacemaker.taxivoyage.main._activity_createmenu(main.java:635)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at peacemaker.taxivoyage.main._onCreateOptionsMenu(main.java:1376)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.runHook(BA.java:155)
    at peacemaker.taxivoyage.main.onCreateOptionsMenu(main.java:136)
    at android.app.Activity.onCreatePanelMenu(Activity.java:2508)
    at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:364)
    at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:93)
    at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:332)
    at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:93)
    at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:454)
    at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:55)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
    at android.view.Choreographer.doCallbacks(Choreographer.java:579)
    at android.view.Choreographer.doFrame(Choreographer.java:547)

It's on the Main activity, but on the second activity creation of the same BACK menu - no problem, BACK menu works OK.

Any help ?

UPD: activity in some mode is fastly closed, and opened the next activity, so .... when the Sub Activity_CreateMenu(Menu As ACMenu) is fired ?

How to delay, or do not create the menu ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Now no problem here also - i have added Sleep(100) before closing the activity and starting the next one - time to finish the menu creation on old slow device.
Now question is how to prevent menu creation after activity start.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…