Android手機系統版本號、IMEI、手機廠商、手機型號
阿新 • • 發佈:2018-12-10
獲取手機IMEI號
/** * 獲取手機IMEI號 * <p> * 需要動態許可權: android.permission.READ_PHONE_STATE */ public static String GetIMEI(Context context) { if (Build.VERSION.SDK_INT >= 23 && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return "使用者未開啟獲取IMEI的許可權"; } TelephonyManager tm = (TelephonyManager) context.getSystemService(Activity.TELEPHONY_SERVICE); if (tm != null) { return tm.getDeviceId(); } else { return "使用者未開啟獲取IMEI的許可權"; } }
獲取當前手機系統版本號
/**
* 獲取當前手機系統版本號
*
* @return 系統版本號
*/
public static String GetSystemVersion() {
return android.os.Build.VERSION.RELEASE;
}
獲取手機廠商
/**
* 獲取手機廠商
*
* @return 手機廠商
*/
public static String GetDeviceBrand() {
return android.os.Build.BRAND;
}
獲取手機型號
/** * 獲取手機型號 * * @return 手機型號 */ public static String GetSystemModel() { return android.os.Build.MODEL; }