In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of how to replace IMEI with Android_id in Android, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value, I believe you will have something to gain after reading this Android article on how to replace IMEI with Android_id. Let's take a look.
Pre-work:
The project configuration is upgraded to the corresponding version 29
CompileSdkVersion: 29
BuildToolsVersion: '29.0.0'
MinSdkVersion: 19
TargetSdkVersion: 29
JavaVersion: JavaVersion.VERSION_1_8
The old version of the method to get IMEI:
Public static String getIMEI (Context context) {String deviceId = null; try {TelephonyManager tm = (TelephonyManager) context .getSystemService (Context.TELEPHONY_SERVICE); deviceId = tm.getDeviceId (); if (deviceId = = null | | ".equals (deviceId)) {return getLocalMacAddress (context);}} catch (Exception e) {e.printStackTrace () If (deviceId = = null | | ".equals (deviceId)) {return getLocalMacAddress (context); / / get the Mac address. In the Android 9p version, the address will change randomly and cannot be used as a unique identity. It can be removed. }} return deviceId;}
Android Q gets IMEI method
Public static String getIMEI (Context context) {String deviceId = null; try {TelephonyManager tm = (TelephonyManager) context .getSystemService (Context.TELEPHONY_SERVICE); if (Build.VERSION.SDK_INT > = Build.VERSION_CODES.Q) {deviceId = Settings.System.getString (context.getContentResolver (), Settings.Secure.ANDROID_ID) } else {/ / request old storage permission if (ActivityCompat.checkSelfPermission (context, Manifest.permission.READ_PHONE_STATE)! = PackageManager.PERMISSION_GRANTED) {/ / TODO: Consider calling / / ActivityCompat#requestPermissions / / here to request the missing permissions, and then overriding / / public void onRequestPermissionsResult (int requestCode, String [] permissions / / int [] grantResults) / / to handle the case where the user grants the permission. See the documentation / / for ActivityCompat#requestPermissions for more details. Return null;} deviceId = tm.getDeviceId ();} if (deviceId = = null | | ".equals (deviceId)) {return getLocalMacAddress (context);}} catch (Exception e) {e.printStackTrace (); if (deviceId = = null | |" .equals (deviceId)) {return getLocalMacAddress (context);}} return deviceId;}
Google officially announced that the phone will be restored to factory settings and Android ID will be reset.
If the user denies permission, the device identity will still not be obtained.
This is the end of the article on "how to replace IMEI with Android_id in Android". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to replace IMEI with Android_id in Android". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.