Skip to content

Instantly share code, notes, and snippets.

@jeffypooo
Forked from espinchi/DeviceUtil.java
Last active June 29, 2019 20:37
Show Gist options
  • Save jeffypooo/132529b8093f0235a20092fe56b430ed to your computer and use it in GitHub Desktop.
Save jeffypooo/132529b8093f0235a20092fe56b430ed to your computer and use it in GitHub Desktop.
Check if the running device is an emulator
import android.os.Build;
/**
* Utility methods related to physical devies and emulators.
*/
object Phone {
val isEmulator: Boolean get() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment