Android Question am getting this error in my app. any suggestion of solving

tamba sylvester

Member
Licensed User
Longtime User
Exception java.lang.NullPointerException: Attempt to read from field 'de.amberhome.objects.appcompat.ACToolbarLightWrapper com.betterbetting.alieng.main._actoolbarlight1' on a null object reference
com.betterbetting.alieng.main._activity_createmenu (main.java:491)
java.lang.reflect.Method.invoke (Method.java)
anywheresoftware.b4a.BA.raiseEvent2 (BA.java:186)
com.betterbetting.alieng.main._onCreateOptionsMenu (main.java:1464)
java.lang.reflect.Method.invoke (Method.java)
anywheresoftware.b4a.BA.runHook (BA.java:155)
com.betterbetting.alieng.main.onCreateOptionsMenu (main.java:134)
android.app.Activity.onCreatePanelMenu (Activity.java:2889)
android.support.v4.app.FragmentActivity.onCreatePanelMenu (FragmentActivity.java:362)
android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu (WindowCallbackWrapper.java:98)
android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu (AppCompatDelegateImplBase.java:335)
android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu (WindowCallbackWrapper.java:98)
 

DonManfred

Expert
Licensed User
Longtime User
the error is in my firebase crush report
And the code you are using too? I dont think so.

YOU did wrote the code. And you should be able to post this code; at least the relevant code which can help us to help you finding the problem.

Hiding your code does not help
 
Upvote 0

tamba sylvester

Member
Licensed User
Longtime User
here is the code related to createmenu
B4X:
Sub Activity_Create(FirstTime As Boolean)

badge=badge+1
    CallSub(Me,"btnBadge_Click")


    ToolbarHelper.Initialize
    ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow
    ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png"))
    ACToolBarLight1.InitMenuListener




End Sub


Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ACToolBarLight1_NavigationItemClick
    sm.ShowMenu
End Sub

Sub Activity_CreateMenu(Menu As ACMenu)
    Menu.Clear

    Menu.Add(5, 0, "Today", Null)
    Menu.Add(6, 0, "Review", Null)
    Menu.Add(7, 0, "Share", Null)
    Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(8, 0, "cart", Null)
    Dim bd As BitmapDrawable

    bd.Initialize(refreshbitmap)
    Dim item2 As ACMenuItem = ACToolBarLight1.Menu.Add2(1,1,"Refresh",bd)
    item2.ShowAsAction=item2.SHOW_AS_ACTION_ALWAYS
    item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS

    UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
End Sub


Sub btnBadge_Click
    Try
        UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
    Catch
   
    End Try
   
End Sub

Sub btnClearBadge_Click
    Try
        badge = 0
        UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
    Catch
   
    End Try
End Sub
Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap
    Dim cvs As Canvas
    Dim mbmp As Bitmap
    mbmp.InitializeMutable(32dip, 32dip)
    cvs.Initialize2(mbmp)
    Dim target As Rect
    target.Initialize(0, 0, mbmp.Width, mbmp.Height)
    cvs.DrawBitmap(bmp, Null, target)
    If Number > 0 Then
        cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0)
        cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER")
    End If
    Return mbmp
End Sub
public Sub UpdateIcon(MenuTitle As String, Icon As Bitmap)
    Dim m As ACMenuItem = GetMenuItem(MenuTitle)
    m.Icon = BitmapToBitmapDrawable(Icon)
End Sub
Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable
    Dim bd As BitmapDrawable
    bd.Initialize(bitmap)
    Return bd
End Sub
Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem)

    If Item.id=5 Then
        curtop=0
        ScrollView1.Panel.RemoveAllViews
        ProgressDialogShow("Loading Games....")
        TabStrip1.ScrollTo(0,True)
   
        loadhomegames
        Return
    End If
    If Item.Id=6 Then
        Dim in As Intent
        in.Initialize(in.ACTION_VIEW, "")
        StartActivity(in)
        Return
        End If
    If Item.Id=7 Then
   

        Dim share As Intent
        share.Initialize(share.ACTION_SEND,"")
        share.SetType("text/plain")

        share.PutExtra("android.intent.extra.TEXT","")
        share.WrapAsIntentChooser("Share text via")
        StartActivity(share)
        Return
    End If

    If Item.Id=8 Then
        CallSub(Me,"btnClearBadge_Click")
        StartActivity(notifications)
        Return
    End If
    Dim Position As Int=    TabStrip1.CurrentPage
    If Position=1 Then
        curtop=0
        ScrollView2.Panel.RemoveAllViews
        ProgressDialogShow("Loading Games....")
        loadlivegames
    End If
    If Position=0 Then
        curtop=0
        ScrollView1.Panel.RemoveAllViews
        ProgressDialogShow("Loading Games....")
        loadhomegames
    End If
    If Position=2 Then
        curtop=0
        ScrollView3.Panel.RemoveAllViews
        ProgressDialogShow("Loading Games....")
        loadnewgames
    End If
    If Position=3 Then
        curtop=0
        ScrollView4.Panel.RemoveAllViews
        ProgressDialogShow("Loading Games....")
        loadmygames
    End If

End Sub
Sub GetMenuItem(Title As String) As ACMenuItem
    For i = 0 To ACToolBarLight1.Menu.Size - 1
        Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i)
        If m.Title = Title Then
            Return m
        End If
    Next
    Return Null
End Sub
#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
 
Upvote 0
Top