Android 关于android.os.Build介绍
关于Build类的介绍
这个类为一个获取设备一些初始化信息的类,该类的主要信息都是通过一些static的字段获得:
public static final String | BOARD | The name of the underlying board, like "goldfish".(设备厂商) |
public static final String | BOOTLOADER | The system bootloader version number. |
public static final String | BRAND | The brand (e.g., carrier) the software is customized for, if any. |
public static final String | CPU_ABI | The name of the instruction set (CPU type + ABI convention) of native code. |
import android.content.Context;
import android.telephony.TelephonyManager;
/**
* 读取手机设备信息测试代码
* http://www.souapp.com 搜应用网
* song2c@163.com
* 宋立波
*/
public class PhoneInfo {
private TelephonyManager telephonyManager;
/**
* 国际移动用户识别码
*/
private String IMSI;
private Context cxt;
public PhoneInfo(Context context) {
cxt=context;
telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
}
/**
* 获取电话号码
*/
public String getNativePhoneNumber() {
String NativePhoneNumber=null;
NativePhoneNumber=telephonyManager.getLine1Number();
return NativePhoneNumber;
}
/**
* 获取手机服务商信息
*/
public String getProvidersName() {
String ProvidersName = "N/A";
try{
IMSI = telephonyManager.getSubscriberId();
// IMSI号前面3位460是国家,紧接着后面2位00 02是中国移动,01是中国联通,03是中国电信。
System.out.println(IMSI);
if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
ProvidersName = "中国移动";
} else if (IMSI.startsWith("46001")) {
ProvidersName = "中国联通";
} else if (IMSI.startsWith("46003")) {
ProvidersName = "中国电信";
}
}catch(Exception e){
e.printStackTrace();
}
return ProvidersName;
}
public String getPhoneInfo(){
TelephonyManager tm = (TelephonyManager)cxt.getSystemService(Context.TELEPHONY_SERVICE);
StringBuilder sb = new StringBuilder();
sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId());
sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion());
sb.append("\nLine1Number = " + tm.getLine1Number());
sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso());
sb.append("\nNetworkOperator = " + tm.getNetworkOperator());
sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName());
sb.append("\nNetworkType = " + tm.getNetworkType());
sb.append("\nPhoneType = " + tm.getPhoneType());
sb.append("\nSimCountryIso = " + tm.getSimCountryIso());
sb.append("\nSimOperator = " + tm.getSimOperator());
sb.append("\nSimOperatorName = " + tm.getSimOperatorName());
sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber());
sb.append("\nSimState = " + tm.getSimState());
sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId());
sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber());
return sb.toString();
}
}