I have read this stackoverflow thread already and I tried using the code given in that answer to find out if I run my code on the emulator or on a real device:
This should do it:
boolean inEmulator = false; String brand = Build.BRAND; if (brand.compareTo("generic") == 0) { inEmulator = true; }
EDIT:
boolean inEmulator = "generic".equals(Build.BRAND.toLowerCase());