Android 關於android.os.Build介紹

來源:互聯網
上載者:User

標籤:android   http   io   ar   os   sp   for   java   on   

關於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 搜應用網 
* [email protected]
* 宋立波
*/
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();
}
}

Android 關於android.os.Build介紹

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.