How to find out from code if my Android app runs on emulator or real device?

后端 未结 9 2256

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:



        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 17:58

    Following one is correctly detect my emulator

    if (Build.BRAND.equalsIgnoreCase("generic")) {
                  //"YES, I am an emulator"
           } else {
                  //"NO, I am NOT an emulator"
           }
    

提交回复
热议问题