1.方法一
private boolean hasNavBar() {
int id = getActivity().getResources().getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0) {
return getActivity().getResources().getBoolean(id);
}
return false;
}
2.方法二
导入
import android.os.RemoteException;
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;
public static boolean hasNavBar() {
boolean hasNavigationBar = false;
try {
IWindowManager mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
if (mWindowManagerService.hasNavigationBar()) {
hasNavigationBar = true;
}
} catch (RemoteException ex) {
//
}
return hasNavigationBar;
}