Android ICS : How to detect that a device have "on screen Back/Home button" (Like Galaxy Nexus)
Asked Answered
A

1

11

I wanted to know if there was a way to detect if the device have "on screen buttons" (like the Galaxy Nexus or ICS tablets)

My issue is that in devices with on screen button, on the action, bar the overflow button is added (if overflow), and not on other devices, so I would like to be able to predict this kind of behavior.

Thank you for your help.

Anthracoid answered 2/2, 2012 at 0:12 Comment(9)
Why do you care, so long as the user has access to the overflow?Lunseth
CommonsWare is right, why do you feel the need to predict this behavior?Waterish
Honeycomb tablets also have "on screen buttons"Pothunter
@Lunseth : the need is to have consistency : having a button on the action bar that act as an overflow when supported (HoneyComb & ICS) and a button that act as if the user pressed the "hardware menu button" on his phone. So that all users have on the action bar the info that there is more options if you press the "overflow button". I understand that this is not classic behavior since they already have the hardware menu button, but I think that the "overflow button" is a nice way to inform the user "there is more options". The other need is to find out if there actually "is" a way ;)Anthracoid
"the need is to have consistency" -- which is why you need to leave things alone. The vast majority of your users do not have both an Android device with a hardware MENU button and an Android device without a hardware MENU button. They do not care what the other type of device behaves like -- they want their apps to behave like all their other apps. You are just like those who think their Android apps have to look identical to their iOS apps, not realizing that very few people ever compare the two side by side, and using screwed up Android navigation as a result.Lunseth
I understand you point, but seeing that the android developer blog says : "In order to provide the most intuitive and consistent user experience in your apps, you should migrate your designs away from using the Menu button and toward using the action bar."(android-developers.blogspot.com/2012/01/… ), I wanted to add action bar that is consistent between all users and wanted to have an interface with "make actions from the user options immediately visible and quick to invoke". Should I remove the actionbar for API 10- ?Anthracoid
Overflow does not show up on devices with a hard menu key because those devices already have a known mechanism for showing overflow - the menu key. You should not be aiming for pixel-perfect consistency for all users of your app on different devices, you should be aiming for consistency with other apps on the same device. Android devices have many hardware variations: screen size, reliance on a hard keyboard/soft keyboard, etc. You wouldn't want tablet users to use a UI intended for a phone for the sake of consistency with phone users any more than you want overflow buttons + hard menu keys.Waterish
As much as I understand your point, the fact is that even with the "already known ùechanism for showing overflow", I kept having request for functions that where hidden in the app, and since I have added it (not on ICS without HW screen button obviously since I still did not found out how to detect it), analytics show that people use the functions more and I get way less request for functions in the overflow. I understand your point, but if there is a trick to get less annoyed user and use the good practice since google ask to "give up on the menu button", I want to try it.Anthracoid
I have found an answer to my question here #9045407 .Anthracoid
E
11

From your Activity you can run the following command:

boolean hasNavigationBar = false;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
{
    hasNavigationBar = !ViewConfiguration.get(context).hasPermanentMenuKey();
}    
else 
{
    hasNavigationBar = false;
}
Eighty answered 27/2, 2013 at 15:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.