user1529408
user1529408

Reputation: 319

How to find out if an android device has back and menu button as part of screen

I see in shops now that device (mostly tablets) have the back and menu buttons as part of the actual screen. As I can't afford another device and mine has back and menu buttons not part of the screen, will my app be able to make use of these if it uses the whole screen. I am using

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

to make it full screen.

If these buttons do get lost is there a way of finding this out, so as to put on screen alternatives for such devices. Also note that I am using minSdkVersion="7", meaning I would like it to work on anything from 2.1 upwards.

Upvotes: 2

Views: 859

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75645

Menu button was removed in Honeycomb. You can check API version and blindly assume if it is Honeycomb, then Menu button is not there by default (it will be added when using legacy application though). You can check API version that way:

if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
  // no menu button by default..
}

These control buttons (home, back and recent apps) are always part of the screen, even in full screen (it can be dimmed, but not removed)

EDIT: however on-screen "Menu" key is not present in Honecomb by default, when you launch legacy application that is not build with targetSdk=11 (or above) then Android will show you that button (otherwise user would not be able to use the app fully). In general - if your app does NOT need menu button at all, then set targetSdk to Honeycomb and up. If you need it, set targetSdk to lower value and Android will take care of this case

Upvotes: 1

Related Questions