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:08

Simple as that with adb

adb devices -l
查看更多
Animai°情兽
3楼-- · 2020-05-16 00:13

Use getprop net.hostname which has an Android unique Id followed by keyword android-<64 bit Hexadecimal String>

example:

[net.hostname]: [android-a487e0560d669e4a]
查看更多
家丑人穷心不美
4楼-- · 2020-05-16 00:14

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
查看更多
Anthone
5楼-- · 2020-05-16 00:14

The Android serial number can be retreived within the device with getprop :

getprop ro.serialno

From Java, you may want to execute it with Runtime.exec()

查看更多
forever°为你锁心
6楼-- · 2020-05-16 00:16

you should probably use IMEI:

    TelephonyManager m = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String imei = m != null ? m.getDeviceId() : null;
查看更多
太酷不给撩
7楼-- · 2020-05-16 00:17

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

adb -s <YOUR-DEVICE-ID> shell getprop
查看更多
登录 后发表回答