Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Make device not run on emulator or rooted device

import android.app.Application;
import android.os.Build;

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        if (isEmulator()) throw new IllegalStateException();
    }

    private boolean isEmulator() {
        return (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
                || Build.FINGERPRINT.startsWith("generic")
                || Build.FINGERPRINT.startsWith("unknown")
                || Build.HARDWARE.contains("goldfish")
                || Build.HARDWARE.contains("ranchu")
                || Build.MODEL.contains("google_sdk")
                || Build.MODEL.contains("Emulator")
                || Build.MODEL.contains("Android SDK built for x86")
                || Build.MANUFACTURER.contains("Genymotion")
                || Build.PRODUCT.contains("sdk_google")
                || Build.PRODUCT.contains("google_sdk")
                || Build.PRODUCT.contains("sdk")
                || Build.PRODUCT.contains("sdk_x86")
                || Build.PRODUCT.contains("vbox86p")
                || Build.PRODUCT.contains("emulator")
                || Build.PRODUCT.contains("simulator");
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: maximum valid parentheses 
Java :: private void loadmaze(string mazefile) 
Java :: action performed java swing code 
Java :: if en une seul ligne java 
Java :: Java pollfirst() and pollLast() Methods 
Java :: Based on the method exampleMethod, what is the return type of the method? 
Java :: android paint drawtext multiline 
Java :: how to wait in the javaprogram 
Java :: reset a jTable without deleting rows 
Java :: string expression execution for java 
Java :: younger brother of java 
Java :: public class MyClass { public static void main(String[] args) { System.out.println("Hello World"); } } 
Java :: how to declare an array list of a clas 
Java :: castle stones java qn 
Java :: how to convert string to space separated int in java 
Java :: java sin-1 
Java :: how to extract value from payload in java 
Java :: what does the continue keyword do in java 
Java :: Java Single-line Comment 
Java :: java no name array eg 
Java :: set countdown timer to play audio file android studio 
Java :: java anomymous code block 
Java :: Eclipse find/replace pluggin 
Java :: spring service discovery 
Java :: Dio.java 
Java :: exception handling and reprompting 
Java :: java gui lookandfeel flatlaf background color 
Java :: masquer saisie mot de passe java console 
Java :: sendPlanUpgrade 
Java :: Save SQLite returned data to an object list 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =