Created
March 31, 2019 03:46
-
-
Save arman-hpp/d08aecbb0b7383d121620d3f58989ea5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string GetImei() | |
{ | |
var permissionCheck = ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadPhoneState); | |
if (permissionCheck == Permission.Denied) | |
{ | |
ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.ReadPhoneState }, 0); | |
} | |
var mTelephonyMgr = (TelephonyManager)GetSystemService(TelephonyService); | |
if (Build.VERSION.SdkInt >= BuildVersionCodes.O) | |
return mTelephonyMgr.GetImei(0); // Some phones has more than 1 SIM card or may not have a SIM card inserted at all | |
#pragma warning disable CS0618 // Type or member is obsolete | |
return mTelephonyMgr.DeviceId; | |
#pragma warning restore CS0618 // Type or member is obsolete | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment