Android Question Activity.OpenMenu and Android 5.0.2

mauro vicamini

Active Member
Licensed User
Longtime User
Hi Everyone!
I've a problem: I've an application that open a menu clicking on an image calling Activity.OpenMenu. Everything works great on Android prior 5.0 , on my Android 5.0.2 (Samsung Galaxy Tab A) it doesn't appear when I click on the image.
Is it a bug or do I have to consider something more (maybe something in manifest or some other option)?

Thanks.
 

mauro vicamini

Active Member
Licensed User
Longtime User
Try it in a new project, with this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.AddMenuItem("asdasd", "aaa")
   Activity.AddMenuItem("asdasd", "aaa")
   Activity.AddMenuItem("asdasd", "aaa")
End Sub

Sub Activity_Click
   Activity.OpenMenu
End Sub

Does it work?
yes it works! So why in my project doesn't work? I do Activity.AddMenuItem like you do in Activity_Create and I call Activity.OpenMenu in image_click event, nothing more. What could it be the problem?
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
I think to have found the problem: the diference between your example and my application is that in may application the Activity is set with #IncludeTitle: false. If i do the same with your example it doesn't works, exactly like my app. But calling Activity.OpenMenu in an Activity with no title works on previous Android versions, also in devices without hardware menu button.
 
Upvote 0

mauro vicamini

Active Member
Licensed User
Longtime User
Indeed this is the way I used to do it and all was OK, but I am afraid that this also does not work anymore in Android version 5.0 and higher. If the title (activity) bar is hidden then calling Activity.OpenMenu does NOT open any menu!
I know this 100% sure because I was getting complaints from customers that they could not open the Menu in my apps. So I did a number of experiments.
You are right Rick! It's the same I've experienced and made me open this thread.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tested it on Android 6 and it does work. The menu appears from the bottom of the screen.

Make sure to test it with the material theme (don't set any specific theme).

upload_2016-3-4_10-41-56.png
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've used this manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
  android:normalScreens="true"
  android:smallScreens="true"
  android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

It will work on all devices running Android 2.0+.
 
Upvote 0
Top