문제

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?

도움이 되었습니까?

해결책

You'll need to add the following permission in the manifest file

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top