Getting Android Device Identifier From ADB and And

2020-05-15 23:23发布

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 'devices' command, the serial number of my connected device is outputted to the screen. I have yet to identify a method in the Android sdk to get me the same serial number.

I don't care what unique identifier is used, just something that can be easily retrieved from both the adb and android sdk. Rooting a device will not be an option.

标签: android adb
10条回答
趁早两清
2楼-- · 2020-05-16 00:19

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

查看更多
趁早两清
3楼-- · 2020-05-16 00:20

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\'"
查看更多
一夜七次
4楼-- · 2020-05-16 00:22

Try ANDROID_ID. As documentation says "[it] is randomly generated on first boot and should remain constant for the lifetime of the device".

查看更多
SAY GOODBYE
5楼-- · 2020-05-16 00:26

I use adb. First I list the attached device ID numbers with the following command:

adb devices

And the output will look something like this:

List of devices attached
YOGAA1BBB412    device

From the previous output, you will need the device ID number (eg: YOGAA1BBB412). To get the Device ID, I use the following adb command:

adb -s YOGAA1BBB412 shell getprop | grep product.model

And the output looks like this:

[ro.product.model]: [Lenovo YT3-X90F]
查看更多
登录 后发表回答