0

Does anyone knows how to retrieve Serial Number of android in C# Xamarin Forms?

I am developing for Android Version 11 and found out that some coding are not working as it is only compatible for below Android Version 11.

If I write below code, I can get the Unique ID but I just want the Serial Number from the device so that the users can know what device.

enter image description here

[assembly: Xamarin.Forms.Dependency(typeof(AndroidDevice))]

public class AndroidDevice : IAndroidDevice
{
    public string GetID()
    {
        return Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
    }
}

How to retrieve that serial number?

DANIELKT
  • 13
  • 5
  • You can check this [Restriction on non-resettable device identifiers](https://developer.android.com/about/versions/10/privacy/changes#non-resettable-device-ids). Starting in Android 10, apps must have the `READ_PRIVILEGED_PHONE_STATE `privileged permission in order to access the device's non-resettable identifiers, which include both IMEI and serial number. – Guangyu Bai - MSFT Jan 13 '23 at 05:05

0 Answers0