如何检查安卓应用程序是否在移动安卓设备或桌面安卓设备(android-x86操作系统)上运行



我正在做一个项目,我需要知道应用程序正在安卓移动设备或安卓桌面设备上运行。我已经在我的电脑上安装了Android-x86操作系统,我正在为Android-x86制作应用程序。如何知道我们的代码正在安卓移动设备或安卓桌面设备上运行?

试试这个

public boolean isGenymotionEmulatorDevice(String manufacturer) {
return manufacturer.toUpperCase().contains("GENYMOTION");
}
public boolean isGoogleEmulatorDevice(String model) {
String modelUpper = model.toUpperCase();
return modelUpper.contains("GOOGLE_SDK")
|| modelUpper.contains("SDK")
|| modelUpper.contains("EMULATOR");
}

使用

boolean isGenymotionEmulator = isGenymotionEmulatorDevice(Build.MANUFACTURER)
boolean isGoogleEmulator = isGoogleEmulatorDevice(Build.MODEL)

最新更新