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.
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
:
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).