请问怎样判断程序运行在模拟器还是真机上? 怎样判断程序运行在模拟器还是真机上?没有API 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 尝试一下设备ID,IMEI code 模拟器为NULL。TelephonyManager tm=(TelephonyManager )activity.getSystemService(Context.TELEPHONY_SERVICE); if(tm==null || !this.hasTelephony()) { Log.v(TAG, "Can't get telephony service. Forcing shut down!"); return false; } String deviceId=tm.getDeviceId(); if(deviceId==null || deviceId.length() < 2) { Log.v(TAG, "Looks like emulator - bail out!"); Toast.makeText(activity, "This special version not intended to run in this device!", 5000).show(); return false; } 谁来看看这个logcat代表什么意思啊,怎么搞定它? android通讯录中搜索框和listview的问题,求解 关于android sdk+MyEclipse+adt 配置与开发 已经解决 学习Android必会的JAVA技术 一个关于googleMap的空指针异常 请问我到安卓市场提交程序的时候说在htc g12 4.04上有问题该怎么办呢 android.v7 support 求助 谁写过android疯狂讲义最后的那个电子拍卖系统啊? 怎么使用ocr技术 程序员的第二职业 怎样判断程序运行在模拟器还是真机上? android客户端与服务器端除了通过wifi和蓝牙还能通过什么交换
TelephonyManager tm=(TelephonyManager )activity.getSystemService(Context.TELEPHONY_SERVICE);
if(tm==null || !this.hasTelephony())
{
Log.v(TAG, "Can't get telephony service. Forcing shut down!");
return false;
}
String deviceId=tm.getDeviceId();
if(deviceId==null || deviceId.length() < 2)
{
Log.v(TAG, "Looks like emulator - bail out!");
Toast.makeText(activity, "This special version not intended to run in this device!", 5000).show();
return false;
}