0

i would like to explain in more detail,

some of android device have action button like this, enter image description here

while some of device have like,

enter image description here

in first case all action button is outside the screen while in second case action button is given bottom of screen(inside the screen)... how can i detect that where the action button is present? i have no idea about it..!!

Mayur R. Amipara
  • 1,223
  • 1
  • 11
  • 32

4 Answers4

1

Check the official Android docs : http://developer.android.com/reference/android/view/KeyCharacterMap.html#deviceHasKey%28int%29

The method deviceHasKey will solve your problem. (Use Keycodes KEYCODE_MENU, KEYCODE_HOME, KEYCODE_BACK). Hope it helps.

gaurav jain
  • 3,119
  • 3
  • 31
  • 48
1

Maybe by doing the following check in your onCreate():

for api 14 and up

boolean PermanentMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey(); // true if physical, false if virtual

for lower api:

boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);

if (hasBackKey && hasHomeKey) {
    // no navigation bar, unless it is enabled in the settings
} else {
    // 99% sure there's a navigation bar
}
Strider
  • 4,452
  • 3
  • 24
  • 35
  • 1
    check [Check for navigation bar](http://stackoverflow.com/questions/16092431/check-for-navigation-bar) and [KeyCharacterMap](http://developer.android.com/reference/android/view/KeyCharacterMap.html#deviceHasKey(int)) – Strider Apr 15 '15 at 07:45
  • thnxx Strider for your ans.! – Mayur R. Amipara Apr 21 '15 at 07:11
0

You may get your answer here. Check for navigation bar

p.s. The formal name of the bar is "Navigation Bar"
https://developer.android.com/training/system-ui/navigation.html

Community
  • 1
  • 1
Jack Fan
  • 2,143
  • 3
  • 18
  • 25
0

found solution here, but not 100% guarantee to work for all device, some device like HTC, LAVA etc not working with that. Also minApi required 13+ for that...!!

Community
  • 1
  • 1
Mayur R. Amipara
  • 1,223
  • 1
  • 11
  • 32