private void GetInformation()
        {
            TelephonyManager phone = this.phoneManager;

            if (phone.GetImei(0) != null)
            {
                exifUserData += "phoneId=" + phone.GetImei(0) + ",";
                if (phone.Line1Number != null)
                {
                    exifUserData += "phoneNr1=" + phone.Line1Number + ",";
                }
                if (phone.SimSerialNumber != null)
                {
                    exifUserData += "simSerial=" + phone.SimSerialNumber + ",";
                }
                if (phone.DeviceSoftwareVersion != null)
                {
                    exifUserData += "phoneSoftwareVersion=" + phone.DeviceSoftwareVersion + ",";
                }

                exifUserData += "androidRelease=" + Android.OS.Build.VERSION.Release + ",";
                exifUserData += "androidManufacturer=" + Android.OS.Build.Manufacturer + ",";
                exifUserData += "androidModel=" + Android.OS.Build.Model + ",";
                exifUserData += "androidProduct=" + Android.OS.Build.Product + ",";
                exifUserData += "androidBrand=" + Android.OS.Build.Brand + ",";
            }//end of if (phone.DeviceId != null)

            try
            {
                PackageInfo info = this.PackageManager.GetPackageInfo(this.PackageName, 0);
                exifUserData += "leafspotAppVersion=" + info.VersionName + ",";
            }
            catch (Exception e)
            { }
        }
Example #2
0
        public string GetIdentifier()
        {
            String ret = "";

            try
            {
                String strDeviceId = Android.Provider.Settings.Secure.GetString(Forms.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

                Context          contexto         = Android.App.Application.Context;
                TelephonyManager telephonyManager =
                    (TelephonyManager)contexto.GetSystemService(Context.TelephonyService);


                if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.O)
                {
                    try
                    {
                        ret = telephonyManager.GetDeviceId(0);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            ret = telephonyManager.GetDeviceId(1);
                        }
                        catch (Exception)
                        {
                            ret = telephonyManager.DeviceId;
                        }
                    };
                }
                else
                {
                    try
                    {
                        ret = telephonyManager.GetImei(0);
                        if (ret == null)
                        {
                            ret = strDeviceId;
                        }
                    }
                    catch (Exception)
                    {
                        try
                        {
                            ret = strDeviceId; //telephonyManager.GetImei(1);
                            //if (ret == null)
                            //    ret = strDeviceId;
                        }
                        catch (Exception)
                        {
                            ret = telephonyManager.Imei;
                        }
                    };
                }
            }
            catch (Exception) { }

            return(ret);
        }
Example #3
0
        public string GetId()
        {
            string           deviceId;
            var              deviceContext = Android.App.Application.Context;
            TelephonyManager mTelephonyMgr = (TelephonyManager)deviceContext.GetSystemService(Android.Content.Context.TelephonyService);

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Q)
            {
                deviceId = Android.Provider.Settings.Secure.GetString(deviceContext.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
            }
            else
            {
                deviceId = mTelephonyMgr.GetImei(0).ToString();
            }

            return(deviceId);
        }