Android Question MenuItem Click Event Force Closes After End Sub

Robert Grabowski

Member
Licensed User
Longtime User
Using the standard action bar or the new app compatibility bars, the following scenario force closes the app within 1 to 3 executions of the menu's click event providing absolutely no log information:

Create overflow menu item.
B4X:
    Activity.AddMenuItem("Fun Fact", "mnuFun")

Create click event to handle the item.
B4X:
Sub mnuFun_Click
    Msgbox("This app will force close AFTER the End Sub", "Force Close Fun")
End Sub

Upon clicking on the menu item between 1 and 3 times, the app will force close. It is chronic when Msgbox or Msgbox2 is in the sub, but it happens under many other conditions. The crash happens somewhere after the End Sub and control never returns to anywhere in the app.

Target devices run Android 5.1. Target SDK 21 and 22 exhibit this behavior. B4A 5.02, up to the minute Android SDK, Java JDK 8.

I really need to be able to use overflow menu items again.
 

Robert Grabowski

Member
Licensed User
Longtime User
I used CallSubDelayed in all my menu click events and it resolved the force close issue in my 10 Activity app.

Thanks again for a great product, excellent technical support, and a pretty good forum.
 
Upvote 0
Top