Hi I want to get IMEI number in my Android device.And I'm able to do it. But I'm getting obsolete warning saying** 'TelephonyManager.DeviceId' is obsolete:'deprecated'**. I'm using this code to get IMEI number in my Android device
Android.Telephony.TelephonyManager mTelephonyMgr; mTelephonyMgr = (Android.Telephony.TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService); return mTelephonyMgr.DeviceId;
right now I'm able to disable the obsolete warning by using
mTelephonyMgr = (Android.Telephony.TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService); #pragma warning disable CS0618 // Type or member is obsolete return mTelephonyMgr.DeviceId; #pragma warning restore CS0618 // Type or member is obsolete
But why I'm getting this obsolete warning? Is there a different approach for getting IMEI number where I wont get this obsolete warning?
I'm creating a Tracking app which fetches the IMEI number of the device and tracks it. I have fixed the issue.This is my code
Android.Telephony.TelephonyManager mTelephonyMgr; mTelephonyMgr = (Android.Telephony.TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService); return mTelephonyMgr.Imei;
This doesn't show me any obsolete warning.
Answers
Out of personal curiosity only... Why does your app need that kind of information? It seems very invasive.
I'm creating a Tracking app which fetches the IMEI number of the device and tracks it. I have fixed the issue.This is my code
This doesn't show me any obsolete warning.