728x90
728x170

private string GetDeviceSerialNumber()

        {

            // https://gist.github.com/flawyte/efd23dd520fc2320f94ba003b9aabfce

            try

            {

                Java.Lang.String sn = null;

                Java.Lang.Class c = Java.Lang.Class.ForName("android.os.SystemProperties");

                Method get = c.GetMethod("get", Java.Lang.Class.FromType(typeof(Java.Lang.String)));

 

                sn = (Java.Lang.String)(get.Invoke(c, "sm.sn1"));

 

                if (string.IsNullOrEmpty(sn.ToString()))

                {

                    sn = (Java.Lang.String)(get.Invoke(c, "gsm.sn1"));

                }

 

                if (string.IsNullOrEmpty(sn.ToString()))

                {

                    sn = (Java.Lang.String)(get.Invoke(c, "ril.serialnumber"));

                }

                

                if (string.IsNullOrEmpty(sn.ToString()))

                {

                    sn = (Java.Lang.String)(get.Invoke(c, "sys.serialnumber"));

                }

 

                if (string.IsNullOrEmpty(sn.ToString()))

                {

                    sn = (Java.Lang.String)(get.Invoke(c, "ro.serialno"));

                }

 

                if (sn == null)

                    return "";

 

                else

                    return sn.ToString();

            }

 

            catch (global::Java.Lang.Exception ex)

            {

                return "";

            }

        }

 

728x90
그리드형
Posted by kjun.kr
,