Last active
October 13, 2021 17:29
-
-
Save radixdev/3de387abae3a724cdcefd48e4925cba0 to your computer and use it in GitHub Desktop.
detects emulators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.radix.triviaassistant.models.util; | |
import android.os.Build; | |
import android.os.Bundle; | |
import com.radix.triviaassistant.BuildConfig; | |
import com.radix.triviaassistant.models.events.AnalyticsSingleton; | |
public class EmulatorDetector { | |
// https://stackoverflow.com/questions/2799097 | |
public static boolean isEmulator() { | |
int score = 0; | |
if (Build.PRODUCT.contains("sdk")) { | |
score++; | |
} | |
if ((Build.MANUFACTURER.contains("unknown")) || (Build.MANUFACTURER.contains("Genymotion"))) { | |
score++; | |
} | |
if ((Build.BRAND.equals("generic")) || (Build.BRAND.equals("generic_x86"))) { | |
score++; | |
} | |
if ((Build.DEVICE.startsWith("generic")) || (Build.DEVICE.equals("vbox86p"))) { | |
score++; | |
} | |
if ((Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk")) | |
|| (Build.MODEL.startsWith("Android SDK built for"))) { | |
score++; | |
} | |
if ((Build.HARDWARE.equals("goldfish")) || (Build.HARDWARE.equals("vbox86"))) { | |
score++; | |
} | |
if (Build.FINGERPRINT.contains("generic")) { | |
score++; | |
} | |
return score >= 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment