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:
Following one is correctly detect my emulator
if (Build.BRAND.equalsIgnoreCase("generic")) { //"YES, I am an emulator" } else { //"NO, I am NOT an emulator" }