Reputation: 11
Is there a way to get te serial number of the device (android) in Net Maui?
I tried with the namespace Microsoft.Maui.Devices.DeviceInfo but It doesn't have it. I used to get it in Xamarin.Forms with the nuget Xam.Plugin.DeviceInfo (DeviceInfoPlugin). Is there something similar in Net Maui?
Upvotes: 1
Views: 3595
Reputation: 1802
you can get Android ID with
Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId)
Upvotes: 2
Reputation: 14204
No, you can't get the serial number of the device since android 10.0. The official document about the restriction on non-resettable device identifiers said:
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.
And the READ_PRIVILEGED_PHONE_STATE
permission is a system permission which can't be granted to the third party application.
Upvotes: 1