How to handle the action bar and menu button?

In the game I am developing, I have a game menu that appears when the menu button is pressed. However, I recently found out that in newer versions of Android there is no "Menu" button, but instead an "Action Bar".

To note, I do not use the real Android menu. All I do is detect the click of a menu button and then handle the event from the game. This means that all I need is that the user can click and find that he was clicked.

So my question is: how can I support both the menu button and the new action bar? I want my application to support API levels 7-current.

UPDATE

Well, after reading this article , I would like to rephrase my question. He said that he "adds an overflow button next to the system navigation." My manifest has android: minSdkVersion = "7" android: targetSdkVersion = "13", but the overflow button does not appear on my emulator. The emulator is an API 14 with a WSVGA shell

+6
source share
2 answers

This Android developer blog post contains a good discussion of the design transition from the old menu button to using the new action bar and Action Overflow List.

It also contains some specific suggestions on how to handle your code when moving from pre-level 11 to the new action bar. It may be useful to you, but for your specific application you will need to decide whether you want to display the action bar or not. If not, then you can add a button to your game interface, which duplicates the functionality of a menu button on devices that are.

+3
source

Newer versions of Android have a menu button (see quote below). I think that itโ€™s best for you to hide the action bar, and in your game use the menu button just like on older versions of Android.

Quote from Android 4.0 Compatibility Definition

7.2.3. Navigation Keys The Home, Menu, and Back functions are required for the Android navigation paradigm.

Device implementations MUST make these functions available to the user at any time during application startup.

These functions MAY be implemented using special physical buttons (such as mechanical or capacitive touch buttons) or MAY be implemented using special soft keys, gestures, touch panel, etc. Android 4.0 supports both versions.

and

The device implementation MUST present a menu key for applications when targetSdkVersion <= 10 and SHOULD NOT display a menu key if targetSdkVersion> 10.

+2
source

Source: https://habr.com/ru/post/910049/


All Articles