如何在android中获取IMEI,LAC / CELLID

时间:2011-05-30 18:27:15

标签: java iphone android xcode

如何获取IMEI,LAC / CELLID的数据?这简单吗?在android / iphone中? 你能告诉我几行吗?

2 个答案:

答案 0 :(得分:5)

对于IMEI 是吗

    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String IMEI = tm.getDeviceId();

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

答案 1 :(得分:0)

使用TelephonyManager,如下所示:

TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
String IMEI = tm.getDeviceId();
int lac = location.getLac();
... ...

此外,您应该使用权限:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

希望它有所帮助。