how to get imeid or device id in android in maui?

mc 3,681 Reputation points
2024-03-27T15:05:21.0433333+00:00

can I get the device Id or IMEID

scene is there is many devices and I want to sign them and I have to write something in each device?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,869 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points Microsoft Vendor
    2024-03-28T05:44:28.8033333+00:00

    Hello,

    can I get the device Id or IMEID

    You can get the device id, but you cannot get IMEID for android platform. Starting from Android 10, apps installed from the Google Play Store cannot get IMEI number. You will get this Security Exception.

    You can refer to the following code to get the device ID.

    #if ANDROID
              
                var device_id =  Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
    
    
    #endif
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful