代码:
html_text = (TextView)findViewById(R.id.html_text);
TelephonyManager phoneMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);html_text.setText("手机型号:"+Build.MODEL+",本机号码:"+phoneMgr.getLine1Number()+",SDK版本号:"+Build.VERSION.SDK+",Firmware/OS 版本号:"+Build.VERSION.RELEASE
+",是否有root权限:"+isRoot());
/**
* 判断当前手机是否有ROOT权限
* @return
*/
public boolean isRoot(){
boolean bool = false;
try{
if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())){
bool = false;
} else {
bool = true;
}
// Log.d(TAG, "bool = " + bool);
} catch (Exception e) {
}
return bool;
}
权限:<uses-permission android:name="android.permission.READ_PHONE_STATE" />
备注:当在设置--SIM卡里面修改了本机的号码时,获取的会是修改之后的号码