其中,radio_type通过TelephonyManager.getNetworkType()获取;signal_strength在PhoneStateListener的回调方法onSignalStrengthChanged中可以得到,mobile_country_code:取telephonyManager.getSimOperator()的前3位数字。剩下的cell_id、location_area_code和mobile_network_code根据网络类型不同而不同:
GSM
cell_id: gsmCellLocation.getCid()
location_area_code:gsmCellLocation.getLac()
mobile_network_code:telephonyManager.getSimOperator()第4位以后的数字
CDMA
cell_id 用 BID值替换 cdmaCellLocation.getBaseStationId()
location_area_code 用NID值替换 cdmaCellLocation.getNetworkId()
mobile_network_code用SID值替换 cdmaCellLocation.getSystemId()
WIFI数据可以通过ScanResult获取:
mac_address: scanResult.BSSID
signal_strength: scanResult.level
ssid: scanResult.SSID
通过Android平台上的相关接口获取到这些数据之后可以用JSONString组织JSON串
本文详细介绍了如何在Android平台上通过TelephonyManager和PhoneStateListener获取网络定位信息,包括GSM、CDMA网络的cell_id、location_area_code等,以及WIFI的mac_address、signal_strength和ssid。并提供了通过相关接口获取数据后组织JSON串的方法。

325

被折叠的 条评论
为什么被折叠?



