检查Android手机是模拟器还是真实设备

3

在类似黑莓这样的设备中,我们是否有任何API方法(类似于DeviceInfo.isSimulator())来检查设备是模拟器还是真实设备?


4
可能是 如何检测Android模拟器? 的重复问题。 - Colin Hebert
1个回答

1

由于内部常量似乎不时更改,因此没有一种100%正确的方法来执行此操作。 不过,这对我有效:

if (android.os.Build.MODEL.contains("google_sdk") ||
    android.os.Build.MODEL.contains("Emulator")) {
    // Then you are running the app on the emulator.
}

1
其他建议可以在这里找到:https://dev59.com/k3E85IYBdhLWcg3wYigB?answertab=votes#tab-top - AgentKnopf

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接