package com.water.activity;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
public class MyList extends Activity {
private TelephonyManager telMgr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
telMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if (telMgr.getSimState() == telMgr.SIM_STATE_READY) {
Log.i("MyList", "良好");
} else if (telMgr.getSimState() == telMgr.SIM_STATE_ABSENT) {
Log.i("MyList", "无SIM卡");
} else {
Log.i("MyList", "SIM卡被锁定或未知的状态");
}
Log.i("MyList", "电话状态[0 无活动/1 响铃/2 摘机]:" + getCallState());
Log.i("MyList", "电话方位:" + getCellLocation());
Log.i("MyList", "唯一的设备ID:" + getDeviceId());
Log.i("MyList", "设备的软件版本号:" + getDeviceSoftwareVersion());
Log.i("MyList", "手机号:" + getLine1Number());
Log.i("MyList", "附近的电话的信息:" + getNeighboringCellInfo());
Log.i("MyList", "获取ISO标准的国家码,即国际长途区号:" + getNetworkCountryIso());
Log.i("MyList", "MCC+MNC:" + getNetworkOperator());
Log.i("MyList", "(当前已注册的用户)的名字:" + getNetworkOperatorName());
Log.i("MyList", "当前使用的网络类型:" + getNetworkType());
Log.i("MyList", "手机类型:" + getPhoneType());
Log.i("MyList", "SIM卡的国家码:" + getSimCountryIso());
Log.i("MyList", "获取SIM卡提供的移动国家码和移动网络码.5或6位的十进制数字:" + getSimOperator());
Log.i("MyList", "服务商名称:" + getSimOperatorName());
Log.i("MyList", "SIM卡的序列号:" + getSimSerialNumber());
Log.i("MyList", "SIM的状态信息:" + getSimState());
Log.i("MyList", "唯一的用户ID:" + getSubscriberId());
Log.i("MyList", "取得和语音邮件相关的标签,即为识别符:" + getVoiceMailAlphaTag());
Log.i("MyList", "获取语音邮件号码:" + getVoiceMailNumber());
Log.i("MyList", "ICC卡是否存在:" + hasIccCard());
Log.i("MyList", "是否漫游:" + isNetworkRoaming());
Log.i("MyList", "获取数据活动状态:" + getDataActivity());
Log.i("MyList", "获取数据连接状态:" + getDataState());
// telMgr.listen(PhoneStateListener listener, int events) ;
// 解释:
// IMSI是国际移动用户识别码的简称(International Mobile Subscriber Identity)
// IMSI共有15位,其结构如下:
// MCC+MNC+MIN
// MCC:Mobile Country Code,移动国家码,共3位,中国为460;
// MNC:Mobile NetworkCode,移动网络码,共2位
// 在中国,移动的代码为电00和02,联通的代码为01,电信的代码为03
// 合起来就是(也是Android手机中APN配置文件中的代码):
// 中国移动:46000 46002
// 中国联通:46001
// 中国电信:46003
// 举例,一个典型的IMSI号码为460030912121001
// IMEI是International Mobile Equipment Identity (国际移动设备标识)的简称
// IMEI由15位数字组成的”电子串号”,它与每台手机一一对应,而且该码是全世界唯一的
// 其组成为:
// 1. 前6位数(TAC)是”型号核准号码”,一般代表机型
// 2. 接着的2位数(FAC)是”最后装配号”,一般代表产地
// 3. 之后的6位数(SNR)是”串号”,一般代表生产顺序号
// 4. 最后1位数(SP)通常是”0″,为检验码,目前暂备用
}
private int getCallState() {
return telMgr.getCallState();
}
private CellLocation getCellLocation() {
CellLocation location = telMgr.getCellLocation();
// 请求位置更新,如果更新将产生广播,接收对象为注册LISTEN_CELL_LOCATION的对象,需要的permission名称为ACCESS_COARSE_LOCATION。
// location.requestLocationUpdate();
return location;
}
private String getDeviceId() {
return telMgr.getDeviceId();
}
private String getDeviceSoftwareVersion() {
return telMgr.getDeviceSoftwareVersion();
}
private String getLine1Number() {
return telMgr.getLine1Number();
}
private List<NeighboringCellInfo> getNeighboringCellInfo() {
// List<NeighboringCellInfo> infos = telMgr.getNeighboringCellInfo();
// for (NeighboringCellInfo info : infos) {
// // 获取邻居小区号
// int cid = info.getCid();
//
// // 获取邻居小区LAC,LAC:
// // 位置区域码。为了确定移动台的位置,每个GSM/PLMN的覆盖区都被划分成许多位置区,LAC则用于标识不同的位置区。
// info.getLac();
// info.getNetworkType();
// info.getPsc();
//
// // 获取邻居小区信号强度
// info.getRssi();
// }
return telMgr.getNeighboringCellInfo();
}
private String getNetworkCountryIso() {
return telMgr.getNetworkCountryIso();
}
private String getNetworkOperator() {
return telMgr.getNetworkOperator();
}
private String getNetworkOperatorName() {
return telMgr.getNetworkOperatorName();
}
private int getNetworkType() {
return telMgr.getNetworkType();
}
private int getPhoneType() {
return telMgr.getPhoneType();
}
private String getSimCountryIso() {
return telMgr.getSimCountryIso();
}
private String getSimOperator() {
return telMgr.getSimOperator();
}
private String getSimOperatorName() {
return telMgr.getSimOperatorName();
}
private String getSimSerialNumber() {
return telMgr.getSimSerialNumber();
}
private int getSimState() {
return telMgr.getSimState();
}
private String getSubscriberId() {
return telMgr.getSubscriberId();
}
private String getVoiceMailAlphaTag() {
return telMgr.getVoiceMailAlphaTag();
}
private String getVoiceMailNumber() {
return telMgr.getVoiceMailNumber();
}
private boolean hasIccCard() {
return telMgr.hasIccCard();
}
private boolean isNetworkRoaming() {
return telMgr.isNetworkRoaming();
}
private int getDataActivity() {
return telMgr.getDataActivity();
}
private int getDataState() {
return telMgr.getDataState();
}
}
Android 读取SIM卡参数
最新推荐文章于 2023-10-25 23:30:00 发布