How to Handle Both Action Bar and Menu Button? - android

With the game I'm developing, I have an in-game menu the pops up when the menu button is pressed. However, I recently found out that the newer versions of Android don't have a Menu button, but instead an Action Bar.
To note, I'm not using an actual Android menu. All I'm doing is detecting that the Menu button was pressed, and then handling the event from within the game. Which means all I need is something that the user can press, and detect that it was pressed.
So my question is, how can I support both a menu button and the newer action bar? I would like my app to support API levels 7-current.
UPDATE
Okay, after reading that article, I'd like to rephrase my question. It said that it "adds the action overflow button beside the system navigation." My manifest has android:minSdkVersion="7" android:targetSdkVersion="13" but no overflow button appears on my emulator. The emulator is API 14 with skin WSVGA

This post in the Android Developers blog has a good discussion of the design transition from the old Menu Button to use of the new Action Bar and Action Overflow list.
It also includes some specific suggestions as to how to deal with your code when transitioning from pre-level 11 to the new Action Bar. May be helpful to you but for your specific application you will need to decide if you want to display an action bar or not. If not then you may want to add a button to your game interface that duplicates the functionality of the menu button on devices that have one.

Newer versions of Android do have a Menu button (see quote below). I think you best option is to just hide the Action bar, and have your game use the menu button in the same way as on older Android versions.
Quoting from Android 4.0 Compatibility Definition
7.2.3. Navigation keys
The Home, Menu and Back functions are essential to the Android navigation paradigm.
Device implementations MUST make these functions available to the user at all times when running applications.
These functions MAY be implemented via dedicated physical buttons (such as mechanical or capacitive touch buttons), or MAY be
implemented using dedicated software keys, gestures, touch panel, etc.Android 4.0 supports both implementations.
And:
Device implementation MUST present a Menu key to applications when
targetSdkVersion <= 10 and SHOULD NOT present a Menu key when the
targetSdkVersion > 10.

Related

Android 5 changes operation of user interface buttons. Is there obvious way to recover Kitkat fuctional features?

Quick question, Android related..
How do I display a working "THREE VERTICAL-DOTS" floating action button, to trigger same functionality as Android menu button that worked on Kitkat (Android-4), and all previous Android versions?
Details:
I have an Android app that uses Java Native Interface. It worked fine in Kitkat (Android 4.x series), but in Android 5.x, the menu-options button (three vertical dots) no longer responds. Originally, in Kitkat (Android 4.x), the standard Android menu button brought up the applications configuration menus. Now, in Android-5, the Menu button has been replaced with a "Recent Apps" button (this was a very poor design change - probably the worst basic re-design of a working interface I have seen in 30 years... ). Is there an easy way to use a "floating action button" or something like that, to restore functionality of the standard Android "Menu" button?
On Samsung tablets, one can tweak: "Settings / Accessibility / Dexterity and interaction / Assistant menu " to "On", and then a floating-action-button appears, which then has the three vertical-dots as one of it's optional push-buttons, if invoked. Pressing that three vertical-dots button (on the Samsung FAB (floating-action-button)), triggers the old Kitkat/Android4 menu, and at least Samsung users can alter set my app config parameters.
In my app's AndroidManifest.xml file, I have minSdkVersion="8" and the targetSDKVersion="8". I have tried setting the targetSDKVersion to higher levels, which results in a non-functional floating action button, showing three vertical dots, appearing on the screen.
There must be an obvious way to fix this damage that the Android "Material Girl Design" people did to Android Kitkat(and previous Android vers.) Android Menu Button. I've detailed a work-around for my user-base at this point, and released an new app version which offers details on the work-around - at least for Samsung phone and tablet users, but an in-app button really should just appear to allow the main app configuration menu to be triggered.
I have looked at this:
http://developer.android.com/training/appbar/setting-up.html#utility
Don't want an "Action Bar". My app is a DOS-emulator, and needs all the screen space.
I have also reviewed:
Android Options Menu in Fragment
This gets closer, but rather than trial-and-error, I would like to just jump to the solution, if possible. There must be some code or a feature selection that just fixes the little action button that appears (but does not work), when I set the targetSDKVersion="12" (or higher values), in the AndroidManifest.xml file.
My app uses SDL (Simple DirectMedia Layer) vers. 1.2 and 1.3 to control and draw the screen.
I will post the answer here when I find it. I know it is possible, because Samsung is already doing this, within its "Accessibility/ Dexterity.. /Assistant Menu" feature.

Why use both an overflow menu and a hardware settings button menu to show the same options?

This kind of behaviour appears on devices that have a hardware settings button (e.g. Samsung Galaxy S3). Apps like Hangouts or Slack use both an overflow menu and the menu that appears when pressing the hardware settings button.
Using an overflow button to show exactly the same options as the hardware settings button menu seems redundant to me. It also seems like it stands against best practices. Because such behaviour appears in many popular apps, I think this might confuse the regular user a little bit.
Is this to make the user's transition to newer versions of the Android platform easier?
Is it recommended to implement the options menu this way for such devices?
I suppose so it depends. Even an Samsung G5 or G6 have a hardware menu. Press the multi tasking window for a long time. It does the same as pressing an overflow button. This is so that the uses of older versions of Android can use there accustomed way of using the menu button. This simply provides your app with a richer User experience.
Especially value of minimum SDK version is very low it is recommended to use this to provide a richer User experience to your application. It is your wish as to how the app is supposed to workm

Is it possible to force use of overflow menu to the right of software button?

I have an action bar with many options and a menu.
On devices that don't have menu button, the overflow menu is added to my action bar.
I want to add this overflow menu button to the right of the software buttons, just like application that don't have an action bar, like this :
Is it possible, and, if it's possible, how to do this ?
Is it possible
Yes, if you do not mind your app looking like you are no longer maintaining it, thereby reducing your prospective user base.
Please read Say Goodbye to the Menu Button, particularly this passage:
However, this button doesn’t provide an ideal user experience. In fact, in apps that don’t use an options menu anyway, this action overflow button does nothing and creates user confusion. So you should update your legacy apps to remove the action overflow from the navigation bar when running on Android 3.0+ and begin using the action bar if necessary. You can do so all while remaining backward compatible with the devices your apps currently support.
Talented developers, therefore, are trying to avoid putting that affordance in the system/navigation bar, not adding that affordance.
how to do this ?
Set your android:targetSdkVersion and your android:minSdkVersion to something less than 11.
This button is automatically added by Android if your minSdkVersion and targetSdkVersion are less than API 11. The only exception is that if you set minSdkVersion to 10 or lower, set targetSdkVersion to 11, 12, or 13, and you do not use ActionBar, the system will add the legacy overflow button when running your app on a handset with Android 4.0 or higher.
If your targetSdkVersion and/or minimumSdkVersion are at or over API 11, then you cannot use this button.

android menu button availability

In the past I've kept my game's options behind the physical menu button for these reasons:
I don't have to have on-screen buttons in-game.
The menu action is consistent with the android user experience; it's not something unique to my app.
In some situations Android provides a soft menu button in the bottom system bar. Looking forward, though (e.g. with recent devices and targetSdkVersions), it seems there's no guaranteed way to have a menu button without implementing the new ActionBar.
If my understanding is correct, I see these options:
Use the ActionBar. Say goodbye to a big chunk of screen real-estate, especially in landscape orientation.
Implement my own on-screen menu button. I've seen this in other games, and it strikes me as inconsistent and terrible.
Target an old sdk version. I don't like this.
Is my understanding correct? Anyone have additional suggestions for my list?
relevant links:
http://developer.android.com/design/patterns/compatibility.html
Android Menu Button on 4.0 Devices
Android 3.0 statusbar & targetSdkVersion in manifest, menu button
android honeycomb menu button target
You could implement a tiny , transparent menu button of your own. Many games do that. That way you are not dependent on anyone and you don't loose any screen space.
Edit : Your menu button could then have follow your game's design.
Is my understanding correct?
Yes.
Anyone have additional suggestions for my list?
Your definition of "terrible" differs from mine. IMHO, any game that has its own stylized graphics and look (i.e., just about anything using the Canvas or OpenGL) should have implemented its own "menu" from the outset, and therefore largely would be oblivious to these changes.

way to programatically determine whether an Android device has a menu button?

I need to compensate for the lack of a physical (or even a "soft") menu button on Android 3 tablets. The app I'm working on generally hides the title bar for its activities, but I can't do that if I want the action bar to appear on a tablet. Is there something in the API that I can use to determine whether a device has a menu button?
If I can't find such a function, the only thing I can think of to do is to never hide the title bar on Android 3.0 and later, but that bothers me for two reasons:
I believe Android 3.0 (or a later API) will eventually support phones, which will probably have menu buttons
I would prefer not to hard code that SDK version (perhaps I could never hide the title bar for Android 3.0 and above, but then I run the risk of not hiding the title bar on phones)
LeffelMania has the right idea, but there is a caveat: If you target SDK 11 (3.0) and use a no-title-bar theme or override with a custom title of some sort, you will be just plain menu-less, because on Honeycomb devices with the target set to 11 the options-menu lives in the title bar itself instead of a fake menu button in the bottom status bar. So be careful there! (You can work around this by setting a lower target, or targeting style resources to v11 to use a one of the Holo themes with a titlebar in that case).
DEPRECATED: This answer is no longer accurate, given changes to the Android framework and design guidelines.
Android phones are guaranteed to have a Menu button. All phones pre-Honeycomb have Menu buttons, and Honeycomb features an ever-present software button. If you use the proper callbacks that tie into the Menu button (onCreateOptionsMenu(), onOptionsItemSelected(), etc) you will be safe to receive those callbacks on any device running Android.
As of API level 14, ViewConfiguration.hasPermanentMenuKey() is available to indicate whether a permanent menu key is present.

Categories

Resources