How to detect soft menu key available in android device? -


i check menu key presence in device in android application. achieve used following code detect weather device having hardware menu or not , working fine

!viewconfiguration.get(scscommander.getinstance().getapplicationcontext()).haspermanentmenukey() 

but did not find logic find weather device having soft menu present or not.

please suggest me there way detect soft menu available or not in device.

there no reliable/clean way check if soft menu (aka navigation bar) present or not!

you may try using below code (not tested on devices , not reliable solution anyways):

boolean hasnavbar(context context) {     resources resources = context.getresources();     int id = resources.getidentifier("config_shownavigationbar", "bool", "android");     if (id > 0) {         return resources.getboolean(id);     } else {    // check keys         boolean hasmenukey = viewconfiguration.get(context).haspermanentmenukey();         boolean hasbackkey = keycharactermap.devicehaskey(keyevent.keycode_back);         return !hasmenukey && !hasbackkey;     } } 

here, fetching resource identifier using resources class. looking resource "navigation bar" passed 1st parameter.

the getidentifier returns associated resource identifier. returns 0 if no such resource found. (0 not valid resource id.)

in case if approach fails, in else trying see check if physical keys present on device back or home constitute navigation bar.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -