我正在寻找一种方法来识别外部输入设备。
我注意到 [InputDevice] 类的 Android API 有一个名为 [isExternal] 的函数。但是当我尝试使用它时,它告诉我它无法解析方法。我查看了在线 API 参考并注意到该函数不存在。所以我想知道为什么API中的函数而不是在线参考中的函数。
参考:https : //developer.android.com/reference/android/view/InputDevice.html https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/InputDevice .java
小智 5
isExternal is a hidden method that is not accessible through the SDK. However, you can still invoke it using java reflection.
public boolean isExternal(InputDevice inputDevice) {
try {
Method m = InputDevice.class.getMethod("isExternal");
return (Boolean) m.invoke(inputDevice);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
source: What does @hide mean in the Android source code?
| 归档时间: |
|
| 查看次数: |
358 次 |
| 最近记录: |