我想通过命令行获取Android
手机的SIM卡的IMSI
号码。
android中有没有什么adb命令或者shell命令来解决这个问题?
我试过三星Galaxy ace中的adb shell getprop ril.IMSI
命令,它起作用了。它给了我IMSI
号码。但我在三星Galaxy S3上尝试了同样的命令。它不会返回任何内容。
我只想在Samsung Galaxy S3
中使用命令行获取SIM卡的IMSI
号。(不是Android应用程序代码)使用adb
命令或Android
中的某个外壳命令。
此外,我知道在安卓应用程序中运行的JAVA
中有一个简单的代码,它给出了IMSI
编号:
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
我能以某种方式从命令行运行这段Android Java
代码吗?这也会解决我的问题。
发布于 2013-02-12 01:01:52
要通过adb shell
调用安卓版本5.x-7.x中的TelephonyManager.getSubscriberId()
,请运行:
adb shell service call iphonesubinfo 7
此命令不再(即,在大多数6.0+设备上)需要设备根。
要在设备端正确解析service call
命令输出,并且不需要外部依赖,请参阅我的answer here
有关更多详细信息,请参阅Calling Android services from ADB shell。
发布于 2014-10-16 23:04:39
adb shell getprop ril.iccid.sim1
如果您想知道所有数据,您只能使用adb shell getprop
,它会显示所有数据,并且您会看到一些条目显示了IMSI值,如条目ril.iccid.sim1
或persist.radio.cfu.iccid.0
发布于 2018-10-05 19:37:38
您可以使用下面的代码通过java代码中的命令来获取ccid。
public static String getSIMCCIDByCmd() {
try {
Process getSimCCIDProc = Runtime.getRuntime().exec(new String[]{"getprop", "ril.iccid.sim1"});
try (final BufferedReader b = new BufferedReader(new InputStreamReader(getSimCCIDProc.getInputStream()))) {
String ccid = b.readLine();
return ccid;
} catch (final IOException e) {
DadsHelper.LOG(TAG, "Exception while reading inputstream", e);
return null;
}
}
catch (Exception e) {
DadsHelper.LOG(TAG,"Exception in getSIMCCID",e);
return null;
}
}
上面的代码使用: getprop命令从属性管理器获取值。
https://stackoverflow.com/questions/14813875
复制相似问题