Getting Android Device Identifier From ADB and Android SDK

前端 未结 12 913
一生所求
一生所求 2021-01-30 17:24

I am looking for the easiest way to get a unique android device identifier from both the Android adb and the Android ADK itself.

For example, when i use the adb \'devi

相关标签:
12条回答
  • 2021-01-30 17:39

    Android stores all the device related info in one or the other sqlite DB. These databases can be found in /data/data/ folder. To read these databases from adb you will need root permissions.

    The android id is available in /data/data/com.android.providers.settings/databases/settings.db

    So for adb use this command.

    adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value from secure where name = 'android_id'"
    

    **you must be running adb as root in adb

    0 讨论(0)
  • 2021-01-30 17:41

    You would probably want to use ANDROID_ID.

    This is how you can query its value via adb shell:

    settings get secure android_id
    

    Or by querying the settings content provider:

    content query --uri content://settings/secure/android_id --projection value
    
    0 讨论(0)
  • 2021-01-30 17:43

    Simple as that with adb

    adb devices -l
    
    0 讨论(0)
  • 2021-01-30 17:43

    adb shell settings get secure android_id

    This command returns ANDROID_ID but it may not be the same as ANDROID_ID received at code level. The application can use different min API level and the value obtained from adb shell may not match

    It was possible to get the ANDROID_ID from [net.hostname] prop. It worked in API level 23.

    Command to get the android_id for API level 23

    adb shell getprop net.hostname

    In android 8.0 and above this prop returns null due to android privacy policy changes. Hence, ANDROID_ID doesn't remain to be a reliable method of unique device id comparison.

    0 讨论(0)
  • 2021-01-30 17:47

    Please make sure your device is connected by running the below command.

    adb devices -l
    

    after that to get the android id of that device you can run the below command.

    adb shell content query --uri content://settings/secure --where "name=\'android_id\'"
    
    0 讨论(0)
  • 2021-01-30 17:47

    Try this and find the id besides Android. The command gives basically all info about the phone.

    adb -s <YOUR-DEVICE-ID> shell getprop
    
    0 讨论(0)
提交回复
热议问题