【发布时间】:2011-01-15 18:47:23
【问题描述】:
有什么方法可以知道我的应用程序是在模拟器上还是在设备上运行?
【问题讨论】:
标签: android android-emulator device
有什么方法可以知道我的应用程序是在模拟器上还是在设备上运行?
【问题讨论】:
标签: android android-emulator device
我正在使用此代码 sn-p,它适用于 Intel 和 ARM 仿真器:
if (Build.MODEL.contains("google_sdk") ||
Build.MODEL.contains("Emulator") ||
Build.MODEL.contains("Android SDK")) {
RunsInEmulator = true;
}
【讨论】:
Secure.getString(getContentResolver(), Secure.ANDROID_ID);
(其中Secure 是android.provider.Settings.Secure)
该值在模拟器上为 null,在设备上为非 null。
【讨论】: