欢迎来到天天文库
浏览记录
ID:37695015
大小:307.79 KB
页数:11页
时间:2019-05-28
《android GSM+CDMA基站定位》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、androidGSM+CDMA基站定位--获取移动网络相关信息在googleAPI里提供了基站信息的获取类TelephonyManager,通过其方法getCellLocation得到CellLocation即可获取到基站相关信息但CellLocation是个抽象类,所以在具体使用时需要判断接入的网络制式来用其子类CdmaCellLocation或GsmCellLocation来强转CdmaCellLocation对应CDMA网,GsmCellLocation对应GSM网三大网络运营商的网络制式对应如下:移动2G网-->GSM移动3G网-->TD-SCDMA电信2G网-->CDMA电信3G
2、网-->CDMA2000联通2G网-->GSM联通3G网-->WCDMA由此可见移动,联通2G网都可使用GsmCellLocation电信2G,3G网则使用CdmaCellLocation那么移动3G和联通3G又当如何其实经本人亲测,移动3G网也可使用GsmCellLocation,听说是TD-SCDMA衍生于GSM,具体原因咱也不用纠结了,反正能用就是了而联通的WCDMA据说也可使用GsmCellLocation,那姑且就是这样吧,有条件的童鞋试一试吧。对于网络制式的判断调用TelephonyManager.getNetworkType()可有多种情况,如下:NETWORK_TYPE_
3、UNKNOWNNETWORK_TYPE_GPRSNETWORK_TYPE_EDGENETWORK_TYPE_UMTSNETWORK_TYPE_HSDPANETWORK_TYPE_HSUPANETWORK_TYPE_HSPANETWORK_TYPE_CDMANETWORK_TYPE_EVDO_0NETWORK_TYPE_EVDO_ANETWORK_TYPE_EVDO_BNETWORK_TYPE_1xRTTNETWORK_TYPE_IDENNETWORK_TYPE_LTENETWORK_TYPE_EHRPD通过对网络类型判断后获取对应基站信息代码片段如下:Html代
4、码1.publicstaticArrayListgetCellIDInfo(Contextcontext)throwsException{2.3.TelephonyManagermanager=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);4.5.ArrayListCellID=newArrayList();6.CellIDInfocurrentCell=newCellIDInfo();7.8.inttype=manager.
5、getNetworkType();9.Log.d(TAG,"getCellIDInfo-->NetworkType="+type);10.intphoneType=manager.getPhoneType();11.Log.d(TAG,"getCellIDInfo-->phoneType="+phoneType);12.13.if(type==TelephonyManager.NETWORK_TYPE_GPRS//GSM网14.
6、
7、type==TelephonyManager.NETWORK_TYPE_EDGE15.
8、
9、type==TelephonyManager.NETWORK_TYPE
10、_HSDPA)16.{17.GsmCellLocationgsm=((GsmCellLocation)manager.getCellLocation());18.if(gsm==null)19.{20.Log.e(TAG,"GsmCellLocationisnull!!!");21.returnnull;22.}23.24.25.intlac=gsm.getLac();26.Stringmcc=manager.getNetworkOperator().substring(0,3);27.Stringmnc=manager.getNetworkOperator().substring(3,5
11、);28.intcid=gsm.getCid();29.30.currentCell.cellId=gsm.getCid();31.currentCell.mobileCountryCode=mcc;32.currentCell.mobileNetworkCode=mnc;33.currentCell.locationAreaCode=lac;34.35.currentCell.radioType="gsm";36.37
此文档下载收益归作者所有