Android Question A bug keeps hunting me

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello,

I have a bug that keeps hunting me (15 versions now) but i can't figure out what exactly is the problem.
B4X:
java.lang.NullPointerException:
  at gr.taxabro.DiplomaAytokinitou.main._activity_createmenu (main.java:430)
  at java.lang.reflect.Method.invoke (Native Method)
  at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:213)
  at gr.taxabro.DiplomaAytokinitou.main._onCreateOptionsMenu (main.java:1923)
  at java.lang.reflect.Method.invoke (Native Method)
  at anywheresoftware.b4a.BA.runHook (BA.java:182)
  at gr.taxabro.DiplomaAytokinitou.main.onCreateOptionsMenu (main.java:137)
  at android.app.Activity.onCreatePanelMenu (Activity.java:4140)
  at androidx.fragment.app.FragmentActivity.onCreatePanelMenu (FragmentActivity.java:324)
  at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu (WindowCallbackWrapper.java:94)
  at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onCreatePanelMenu (AppCompatDelegateImpl.java:3070)
  at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu (WindowCallbackWrapper.java:94)
  at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu (ToolbarActionBar.java:456)
  at androidx.appcompat.app.ToolbarActionBar$1.run (ToolbarActionBar.java:57)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:969)
  at android.view.Choreographer.doCallbacks (Choreographer.java:793)
  at android.view.Choreographer.doFrame (Choreographer.java:724)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:954)
  at android.os.Handler.handleCallback (Handler.java:914)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:224)
  at android.app.ActivityThread.main (ActivityThread.java:7551)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:995)

B4X:
#If Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
    if (processBA.subExists("activity_createmenu")) {
        processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
        return true;
    }
    else
        return false;
}
#End If

B4X:
#Region TOOLBAR
'Add menu icons
#IgnoreWarnings: 11
Sub Activity_CreateMenu(Menu As ACMenu)

    Menu.Clear
    
    Try
        si = Menu.add2(1, 1, "Αξιολόγηση εφαρμογής", xml.GetDrawable("ic_thumb_up_outline_white_24dp"))
        si.ShowAsAction=si.SHOW_AS_ACTION_IF_ROOM
    Catch
        si = Menu.add2(1, 1, "Αξιολόγηση εφαρμογής", Null)
        si.ShowAsAction=si.SHOW_AS_ACTION_IF_ROOM
    End Try
    
    si = Menu.add2(2, 2, "Δίπλωμα Μοτοσυκλέτας", xml.GetDrawable("ic_motorbike_white_24dp"))
    si.ShowAsAction=si.SHOW_AS_ACTION_IF_ROOM
End Sub

Sub ToolBar_MenuItemClick (Item As ACMenuItem)
    Log("Menuitem: " & Item.Title & " clicked")
    If Item.id=1 Then
        
    Else If Item.id=2 Then
            
    End If
End Sub
#End Region
 
Top