デバイス情報PhoneInfo
2612 ワード
package com.jinshan.test;
import android.content.Context;
import android.telephony.TelephonyManager;
/**
*
*/
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("
DeviceId(IMEI) = " + tm.getDeviceId());
sb.append("
DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion());
sb.append("
Line1Number = " + tm.getLine1Number());
sb.append("
NetworkCountryIso = " + tm.getNetworkCountryIso());
sb.append("
NetworkOperator = " + tm.getNetworkOperator());
sb.append("
NetworkOperatorName = " + tm.getNetworkOperatorName());
sb.append("
NetworkType = " + tm.getNetworkType());
sb.append("
PhoneType = " + tm.getPhoneType());
sb.append("
SimCountryIso = " + tm.getSimCountryIso());
sb.append("
SimOperator = " + tm.getSimOperator());
sb.append("
SimOperatorName = " + tm.getSimOperatorName());
sb.append("
SimSerialNumber = " + tm.getSimSerialNumber());
sb.append("
SimState = " + tm.getSimState());
sb.append("
SubscriberId(IMSI) = " + tm.getSubscriberId());
sb.append("
VoiceMailNumber = " + tm.getVoiceMailNumber());
return sb.toString();
}
}