[英]Gettig Blank IMEI Using Visual Studio 2017 and Xamarin
I am Trying to getting IMEI num of Device using this code.我正在尝试使用此代码获取设备的 IMEI 编号。 When I am Deployint my app I get blank Deviceid where as i am getting devicesoftware version correctly
当我 Deployint 我的应用程序时,我得到空白 Deviceid,因为我正在正确获取 devicesoftware 版本
Android.Telephony.TelephonyManager mTelephonyMgr;
mTelephonyMgr = (Android.Telephony.TelephonyManager)GetSystemService(Context.TelephonyService);
m_deviceId = mTelephonyMgr.DeviceId;
What you need to do is simple你需要做的很简单
Android.Telephony.TelephonyManager mTelephonyMgr;
mTelephonyMgr = (Android.Telephony.TelephonyManager)GetSystemService(Context.TelephonyService);
if (Android.OS.Build.VERSION.SdkInt>= BuildVersionCodes.O)
{
m_deviceId = mTelephonyMgr.Imei;
}
else
{
m_deviceId = mTelephonyMgr.DeviceId;
}
Also make sure you have read phone state permission:还要确保您已阅读电话 state 权限:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.