Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if the running device is an emulator
import android.os.Build;
/**
* Utility methods related to physical devies and emulators.
*/
public class DeviceUtil {
public static boolean isEmulator() {
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);
}
}
@Yousha

This comment has been minimized.

Copy link

commented Sep 9, 2016

Then how to prevent them from running the app in the emulator? while we are developing

@ancuop

This comment has been minimized.

Copy link

commented Mar 2, 2017

Can we prevent app for mobile run on TV and vice versa?
Thank!

@moulichandu

This comment has been minimized.

Copy link

commented Dec 18, 2018

This condition failed when i run the application in blue-stack emulator.

@readmycodetanos

This comment has been minimized.

Copy link

commented Aug 9, 2019

are you kidding me , this not work

@espinchi

This comment has been minimized.

Copy link
Owner Author

commented Aug 10, 2019

Well this did work back in 2015, but I'd be surprised if it still does. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.