Search code examples
androidandroid-studiocodenameone

How to restrict CN1 app from running on Android Studio emulator


Due to app security concern I need to restrict a certain app from being able to run on emulator. How can CN1 android build app be restricted from running on emulators like Android studio and Genymotion emulators?


Solution

  • This seemed like something easy to make so I added it in a PR here. It should be available in next weeks update and would work using code like this in your start method:

    if(getProperty("Emulator", "false").equals("true")) {
        throw new RuntimeException("Emulator not supported");
    }
    

    I based this change on this and this update.