Is there an android shell or adb command that I co

2019-01-11 12:40发布

Is there some adb or android shell command that I could run that would return a device's IMEI or MEID number? Preferably that's all that would be returned.

标签: android adb
7条回答
Evening l夕情丶
2楼-- · 2019-01-11 13:26

As the iphonesubinfo 1 command does not work on many devices, here is a little workaround that should work consistently on most Android versions and on rooted and unrooted devices:

If you already have an own app that you can install on the device that you want to know the IMEI from, add this BroadcastReceiver to your app:

public class GetImeiReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String imei = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
        setResultData(imei);
    }

}

and to the AndroidManifest.xml:

<receiver android:name=".GetImeiReceiver">
  <intent-filter>
    <action android:name="com.myapp.GET_IMEI"/>
  </intent-filter>
</receiver>

Call your receiver over ADB:

adb shell am broadcast -a com.myapp.GET_IMEI

...and the output will be something like:

Broadcast completed: result=0, data="000000000000000"

...where data is the device IMEI.

If you have don't have an existing app to integrate this solution into, I created this simple one which includes the required code: https://github.com/saschoar/android-imei-getter (also includes the APK and full instructions).

查看更多
登录 后发表回答