Я пытаюсь получить unique ID
IMEI
для Android 9.0 API LVL 28
Когда я пытался с моим кодом, у меня появляется эта ошибка:
Java.Lang.SecurityException:getImeiForSlot: Ни пользователь 10154, ни текущий процесс не имеют android.permission.READ_PHONE_STATE.
public class DeviceInfo : IDeviceInfo
{
TelephonyManager telephonyManager;
public DeviceInfo()
{
telephonyManager =
(TelephonyManager)Application.Context.GetSystemService(Context.TelephonyService);
}
public string Id
{
get
{
telephonyManager = (TelephonyManager)Application.Context.GetSystemService(Context.TelephonyService);
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
// TODO: Some phones has more than 1 SIM card or may not have a SIM card inserted at all
return telephonyManager.GetMeid(0);
else
#pragma warning disable CS0618 // Type or member is obsolete
return telephonyManager.DeviceId;
#pragma warning restore CS0618 // Type or member is obsolete
}
}
и мой androdManifest.xml
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />