android读取短信内容简书,Android 基础信息获取

Android 基础信息获取

持续更新中。。。

1、设备信息

手机号

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number()

IMEI(国际移动设备识别码)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId()

IMSI(国际移动用户识别码)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId()

SIM(序列号)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSimSerialNumber()

SimCountryIso(sim卡国家码)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSimCountryIso()

SimOperatorName(SPN,sim卡运营商名称)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSimOperatorName()

NetworkCountryIso(网络运营商国家码)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkCountryIso()

NetworkOperatorName(网络运营商名称)

((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName()

2、网络

网络类型(wifi、2|3|4g)

public static String getNetWorkType(Context context) {

String type = "";

ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo info = cm.getActiveNetworkInfo();

if (info == null) {

type = "null";

} else if (info.getType() == ConnectivityManager.TYPE_WIFI) {

type = "wlan";

} else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {

int subType = info.getSubtype();

switch (subType) {

case TelephonyManager.NETWORK_TYPE_CDMA:

case TelephonyManager.NETWORK_TYPE_GPRS:

case TelephonyManager.NETWORK_TYPE_EDGE:

case TelephonyManager.NETWORK_TYPE_1xRTT:

case TelephonyManager.NETWORK_TYPE_IDEN:

type = "2g";

break;

case TelephonyManager.NETWORK_TYPE_UMTS:

case TelephonyManager.NETWORK_TYPE_HSDPA:

case TelephonyManager.NETWORK_TYPE_HSUPA:

case TelephonyManager.NETWORK_TYPE_HSPA:

case TelephonyManager.NETWORK_TYPE_EVDO_A:

case TelephonyManager.NETWORK_TYPE_EVDO_0:

case TelephonyManager.NETWORK_TYPE_EVDO_B:

case TelephonyManager.NETWORK_TYPE_EHRPD:

case TelephonyManager.NETWORK_TYPE_HSPAP:

case TelephonyManager.NETWORK_TYPE_TD_SCDMA:

type = "3g";

break;

case TelephonyManager.NETWORK_TYPE_LTE:

type = "4g";

break;

case TelephonyManager.NETWORK_TYPE_UNKNOWN:

default:

type = "cellular";

break;

}

}

return type;

}

WIFI-SSID(无线网络名称)

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);

WifiInfo wifiInfo = wifiManager.getConnectionInfo();

Log.i("NET_CHECK", "wifi - ssid=" + wifiInfo.getSSID());

WIFI-BSSID(无线网络mac地址)

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);

WifiInfo wifiInfo = wifiManager.getConnectionInfo();

Log.i("NET_CHECK", "wifi - ssid=" + wifiInfo.getSSID());

WIFI-DNS(无线网络域名服务器)

public String getDNSServers() {

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);

if (wifiManager == null || !wifiManager.isWifiEnabled()) {

return "";

}

DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();

if (dhcpInfo != null) {

if (dhcpInfo.dns1 != 0) {

return intToIp(dhcpInfo.dns1);

}

if (dhcpInfo.dns2 != 0) {

return intToIp(dhcpInfo.dns2);

}

}

return "";

}

WIFI-信号强度

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);

WifiInfo wifiInfo = wifiManager.getConnectionInfo();

Log.i("NET_CHECK", "wifi - wifi_signal=" + WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 100));

数据-CID(基站id)

TelephonyManager telephonyManager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

CellLocation cellLocation = telephonyManager.getCellLocation();

Log.i("NET_CHECK", "data - cid=" + ((GsmCellLocation) cellLocation).getCid());

数据-LAC(基站位置区码)

TelephonyManager telephonyManager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

CellLocation cellLocation = telephonyManager.getCellLocation();

Log.i("NET_CHECK", "data - lac=" + ((GsmCellLocation) cellLocation).getLac());

数据-MNC(移动网络码)

TelephonyManager telephonyManager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

Log.i("NET_CHECK", "data - mnc=" + Integer.valueOf(networkOperator.substring(3)).intValue());

数据-MCC(移动国家码)

TelephonyManager telephonyManager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

Log.i("NET_CHECK", "data - mcc=" + Integer.valueOf(networkOperator.substring(0, 3)).intValue());

数据-BSSS(信号强度)、TAC(运营商跟踪区代码)

TelephonyManager telephonyManager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

if (telephonyManager.getAllCellInfo() == null) {

Log.i("NET_CHECK", "data - getAllCellInfo returned null");

} else {

for (final CellInfo info : telephonyManager.getAllCellInfo()) {

if (info instanceof CellInfoLte) {

CellIdentityLte lte_cell = ((CellInfoLte) info).getCellIdentity();

Log.i("NET_CHECK", "data - bsss=" + ((CellInfoLte) info).getCellSignalStrength());

Log.i("NET_CHECK", "data - tac=" + lte_cell.getTac());

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值