我对清单设置了read phone state
权限。
该应用程序,但仍无法读取IMEI。
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
public void send() {
final Device activationDevice = DeviceUtil.getInfo(mContext);
String json = gson.toJson(activationDevice.getImeinumber());
//Log.d("activation","send");
try {
volley.post("GetNewActivation", new JSONObject(), new Listener<JSONObject>() {
...
}
}
java.lang.SecurityException:getDeviceId 引起原因:java.lang.SecurityException:getDeviceId
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getImei();
答案 0 :(得分:0)
您需要添加以下权限:
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
https://developer.android.com/reference/android/telephony/TelephonyManager#getImei()