You'll need to add the following permission in the manifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Frage
I'm trying to retrieve the IMEI number of a phone. I'm using code below:
public static string GetDeviceId(Context context)
{
TelephonyManager telephonyMgr = context.GetSystemService(Context.TelephonyService) as TelephonyManager;
string deviceId = telephonyMgr.DeviceId == null ? "UNAVAILABLE" : telephonyMgr.DeviceId;
return deviceId;
}
Is there any problem with the code? What else should I do?
Lösung
You'll need to add the following permission in the manifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE" />