小智 8
你可以用PackageManager.hasSystemFeature().
例:
boolean hasCamera =
getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
Run Code Online (Sandbox Code Playgroud)
您还可以获得一些无法PackageManager通过Configuration例如DPAD 测试的功能.
Configuration c = getResources().getConfiguration();
if(c.navigation == Configuration.NAVIGATION_DPAD)
hasDpad = true;
Run Code Online (Sandbox Code Playgroud)
唯一的例外是搜索按钮.几天前在这里有一个问题,问的基本相同.我不记得任何答案,我不知道检测搜索按钮的方法,因为它不在功能列表中.(编辑:你去,可能重复的线程是我在这里提到的那个)
小智 5
这是检查硬件“菜单”按钮是否存在的好方法:
ViewConfiguration.get(context).hasPermanentMenuKey();
Run Code Online (Sandbox Code Playgroud)
来自:https : //stackoverflow.com/a/9481965 另见:http : //developer.android.com/reference/android/view/ViewConfiguration.html#hasPermanentMenuKey()