我已经阅读了这个stackoverflow主题,并尝试使用那个答案中给出的代码来找出我是在模拟器上运行还是在真实设备上运行:
import android.content.ContentResolver;
import android.provider.Settings.Secure;
...
mTextView.setText(Secure.getString(getContentResolver(), Secure.ANDROID_ID));
在我的真实设备上,它返回"2bccce3...",但是在模拟器上它不会返回null,而是一个字符串"bd9f8..."
有什么方法可以从代码中找出是模拟器还是真实设备将不胜感激
boolean inEmulator = "generic".equals(Build.BRAND);
。 - Ted Hopp