Android ICS:如何检测设备是否具有"屏幕后退/主页按钮"(如Galaxy Nexus)

Ato*_*usk 11 android menu android-4.0-ice-cream-sandwich

我想知道是否有办法检测设备是否有"屏幕按钮"(如Galaxy Nexus或ICS平板电脑)

我的问题是,在具有屏幕按钮的设备上,在操作上,添加溢出按钮(如果溢出),而不是在其他设备上,所以我希望能够预测这种行为.

谢谢您的帮助.

Eya*_*sha 10

从您的Activity中,您可以运行以下命令:

boolean hasNavigationBar = false;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
{
    hasNavigationBar = !ViewConfiguration.get(context).hasPermanentMenuKey();
}    
else 
{
    hasNavigationBar = false;
}
Run Code Online (Sandbox Code Playgroud)