-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
判断手机有没有虚拟按键(NavigationBar)? #4
Comments
你试了嘛 |
我试了,hasMenuKey 返回的是false, hasBackKey 返回的是true |
可以试试这个 我这边几台手机用这个是能判断的 |
@zzkong |
我在Nexus 5上测试 ------结贴----- |
···
// 判断设备是否有返回键、菜单键来确定是否有 NavigationBar
public static boolean hasNavigationBar(Context context) {
boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (!hasMenuKey && !hasBackKey) {
return true;
}
return false;
}
···
按照这种做法,在华为手机5X上,并不能检测出来。
The text was updated successfully, but these errors were encountered: