Java Code Examples for android.telephony.TelephonyManager#getDeviceSoftwareVersion()
The following examples show how to use
android.telephony.TelephonyManager#getDeviceSoftwareVersion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceUtils.java From Android-utils with Apache License 2.0 | 6 votes |
/** * Return the phone status. * <p>Must hold * {@code <uses-permission android:name="android.permission.READ_PHONE_STATE" />}</p> * * @return DeviceId = 99000311726612<br> * DeviceSoftwareVersion = 00<br> * Line1Number =<br> * NetworkCountryIso = cn<br> * NetworkOperator = 46003<br> * NetworkOperatorName = 中国电信<br> * NetworkType = 6<br> * PhoneType = 2<br> * SimCountryIso = cn<br> * SimOperator = 46003<br> * SimOperatorName = 中国电信<br> * SimSerialNumber = 89860315045710604022<br> * SimState = 5<br> * SubscriberId(IMSI) = 460030419724900<br> * VoiceMailNumber = *86<br> */ @SuppressLint("HardwareIds") @RequiresPermission(READ_PHONE_STATE) public static String getPhoneStatus() { TelephonyManager tm = (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE); String str = ""; //noinspection ConstantConditions str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n"; str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n"; str += "Line1Number = " + tm.getLine1Number() + "\n"; str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n"; str += "NetworkOperator = " + tm.getNetworkOperator() + "\n"; str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n"; str += "NetworkType = " + tm.getNetworkType() + "\n"; str += "PhoneType = " + tm.getPhoneType() + "\n"; str += "SimCountryIso = " + tm.getSimCountryIso() + "\n"; str += "SimOperator = " + tm.getSimOperator() + "\n"; str += "SimOperatorName = " + tm.getSimOperatorName() + "\n"; str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n"; str += "SimState = " + tm.getSimState() + "\n"; str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n"; str += "VoiceMailNumber = " + tm.getVoiceMailNumber(); return str; }
Example 2
Source File: PhoneUtils.java From Android-UtilCode with Apache License 2.0 | 6 votes |
/** * 获取手机状态信息 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p> * * @return DeviceId(IMEI) = 99000311726612<br> * DeviceSoftwareVersion = 00<br> * Line1Number =<br> * NetworkCountryIso = cn<br> * NetworkOperator = 46003<br> * NetworkOperatorName = 中国电信<br> * NetworkType = 6<br> * honeType = 2<br> * SimCountryIso = cn<br> * SimOperator = 46003<br> * SimOperatorName = 中国电信<br> * SimSerialNumber = 89860315045710604022<br> * SimState = 5<br> * SubscriberId(IMSI) = 460030419724900<br> * VoiceMailNumber = *86<br> */ @SuppressLint("HardwareIds") public static String getPhoneStatus() { TelephonyManager tm = (TelephonyManager) Utils.getContext() .getSystemService(Context.TELEPHONY_SERVICE); String str = ""; str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n"; str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n"; str += "Line1Number = " + tm.getLine1Number() + "\n"; str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n"; str += "NetworkOperator = " + tm.getNetworkOperator() + "\n"; str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n"; str += "NetworkType = " + tm.getNetworkType() + "\n"; str += "PhoneType = " + tm.getPhoneType() + "\n"; str += "SimCountryIso = " + tm.getSimCountryIso() + "\n"; str += "SimOperator = " + tm.getSimOperator() + "\n"; str += "SimOperatorName = " + tm.getSimOperatorName() + "\n"; str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n"; str += "SimState = " + tm.getSimState() + "\n"; str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n"; str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n"; return str; }
Example 3
Source File: RxDeviceTool.java From RxTools-master with Apache License 2.0 | 6 votes |
/** * 获取手机状态信息 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p> * * @param context 上下文 * @return DeviceId(IMEI) = 99000311726612<br> * DeviceSoftwareVersion = 00<br> * Line1Number =<br> * NetworkCountryIso = cn<br> * NetworkOperator = 46003<br> * NetworkOperatorName = 中国电信<br> * NetworkType = 6<br> * honeType = 2<br> * SimCountryIso = cn<br> * SimOperator = 46003<br> * SimOperatorName = 中国电信<br> * SimSerialNumber = 89860315045710604022<br> * SimState = 5<br> * SubscriberId(IMSI) = 460030419724900<br> * VoiceMailNumber = *86<br> */ public static String getPhoneStatus(Context context) { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String str = ""; str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n"; str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n"; str += "Line1Number = " + tm.getLine1Number() + "\n"; str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n"; str += "NetworkOperator = " + tm.getNetworkOperator() + "\n"; str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n"; str += "NetworkType = " + tm.getNetworkType() + "\n"; str += "honeType = " + tm.getPhoneType() + "\n"; str += "SimCountryIso = " + tm.getSimCountryIso() + "\n"; str += "SimOperator = " + tm.getSimOperator() + "\n"; str += "SimOperatorName = " + tm.getSimOperatorName() + "\n"; str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n"; str += "SimState = " + tm.getSimState() + "\n"; str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n"; str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n"; return str; }
Example 4
Source File: PhoneStateReadTest.java From AndPermission with Apache License 2.0 | 5 votes |
@Override public boolean test() throws Throwable { PackageManager packageManager = mContext.getPackageManager(); if (!packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return true; TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) telephonyManager.getDeviceId(); else telephonyManager.getDeviceSoftwareVersion(); return true; }
Example 5
Source File: MyDialerActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 4 votes |
private void listing20_6() { String srvcName = Context.TELEPHONY_SERVICE; TelephonyManager telephonyManager = (TelephonyManager)getSystemService(srvcName); // Listing 20-6: Accessing phone-type and the device’s phone number String phoneTypeStr = "unknown"; int phoneType = telephonyManager.getPhoneType(); switch (phoneType) { case (TelephonyManager.PHONE_TYPE_CDMA): phoneTypeStr = "CDMA"; break; case (TelephonyManager.PHONE_TYPE_GSM) : phoneTypeStr = "GSM"; break; case (TelephonyManager.PHONE_TYPE_SIP): phoneTypeStr = "SIP"; break; case (TelephonyManager.PHONE_TYPE_NONE): phoneTypeStr = "None"; break; default: break; } Log.d(TAG, phoneTypeStr); // -- These require READ_PHONE_STATE uses-permission -- int permission = ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE); if (permission == PackageManager.PERMISSION_GRANTED) { // Read the IMEI for GSM or MEID for CDMA String deviceId = telephonyManager.getDeviceId(); // Read the software version on the phone (note -- not the SDK version) String softwareVersion = telephonyManager.getDeviceSoftwareVersion(); // Get the phone's number (if available) String phoneNumber = telephonyManager.getLine1Number(); // If permission hasn't been granted, request it. } else { if (ActivityCompat.shouldShowRequestPermissionRationale( this, android.Manifest.permission.READ_PHONE_STATE)) { // TODO Display additional rationale for the requested permission. } ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_PHONE_STATE}, PHONE_STATE_PERMISSION_REQUEST); } }
Example 6
Source File: PhoneUtils.java From Ticket-Analysis with MIT License | 4 votes |
/** * 获取手机状态信息 * <p>需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/> * <p>返回如下 * <pre> * DeviceId(IMEI) = 99000311726612 * DeviceSoftwareVersion = 00 * Line1Number = * NetworkCountryIso = cn * NetworkOperator = 46003 * NetworkOperatorName = 中国电信 * NetworkType = 6 * honeType = 2 * SimCountryIso = cn * SimOperator = 46003 * SimOperatorName = 中国电信 * SimSerialNumber = 89860315045710604022 * SimState = 5 * SubscriberId(IMSI) = 460030419724900 * VoiceMailNumber = *86 * <pre/> */ public static String getPhoneStatus(Context context) { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String str = ""; str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n"; str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n"; str += "Line1Number = " + tm.getLine1Number() + "\n"; str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n"; str += "NetworkOperator = " + tm.getNetworkOperator() + "\n"; str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n"; str += "NetworkType = " + tm.getNetworkType() + "\n"; str += "honeType = " + tm.getPhoneType() + "\n"; str += "SimCountryIso = " + tm.getSimCountryIso() + "\n"; str += "SimOperator = " + tm.getSimOperator() + "\n"; str += "SimOperatorName = " + tm.getSimOperatorName() + "\n"; str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n"; str += "SimState = " + tm.getSimState() + "\n"; str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n"; str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n"; return str; }
Example 7
Source File: RxDeviceTool.java From RxTools-master with Apache License 2.0 | 2 votes |
/** * 获取设备的软件版本号 * * @param context * @return */ public static String getDeviceSoftwareVersion(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceSoftwareVersion(); }