您的位置:首页 > 移动开发 > Android开发

Android基础:获取手机信息

2016-09-28 17:43 387 查看
获取手机的sim信息 、设备编号 、 网络提供商等

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//      sim
String simOperator = tm.getSimOperator();//sim卡提供商编码
String simSerialNumber = tm.getSimSerialNumber();//sim卡序列号
String simOperatorName = tm.getSimOperatorName();//sim提供商名称
String simCountryIso = tm.getSimCountryIso();//sim国家编码
int simState = tm.getSimState();//sim卡状态
String line1Number = tm.getLine1Number();//本机号码(一般获取不到)

//      Device
String deviceId = tm.getDeviceId();//设备编号
String deviceSoftwareVersion = (tm.getDeviceSoftwareVersion() == null)? tm.getDeviceSoftwareVersion() : "未知版本";//系统平台版本

//      Network
String networkOperator = tm.getNetworkOperator();//网络提供商编号
String networkOperatorName = tm.getNetworkOperatorName();//网络提供商名称
String networkCountryIso = tm.getNetworkCountryIso();//网络提供商国家编码
int networkType = tm.getNetworkType();//网络类型

int phoneType = tm.getPhoneType();//手机类型:PHONE_TYPE_NONE + PHONE_TYPE_GSM + PHONE_TYPE_CDMA + PHONE_TYPE_SIP

String location = tm.getCellLocation().toString() == null ? tm.getCellLocation().toString() : "未知地址";//地址(一般获取不到)

Log.d("TAG","simOperator="+simOperator
+"\n"+"simSerialNumber="+simSerialNumber
+"\n"+"simOperatorName="+simOperatorName
+"\n"+"simCountryIso="+simCountryIso
+"\n"+"simState="+simState
+"\n"+"line1Number="+line1Number
+"\n"+"deviceId="+deviceId
+"\n"+"deviceSoftwareVersion="+deviceSoftwareVersion
+"\n"+"networkOperator="+networkOperator
+"\n"+"networkOperatorName="+networkOperatorName
+"\n"+"networkCountryIso="+networkCountryIso
+"\n"+"networkType="+networkType
+"\n"+"phoneType="+phoneType
+"\n"+"location="+location
);


结果:



源码:

PhoneInfo
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: