>基站:CellID和RSS(识别哪一个是基站)
>对于所有neigbouring站:CellID和RSS
有各种API,看起来我必须使用不同的API telephonyManager和PhonestateListener.我有点困惑,因为我认为这应该在一个界面中可用.此外,我认为应该可以轮询当前基站的CellID,而不必监听状态更改以确定int,因为也可以从telephonyManager轮询相邻的Cell Stations.
你能告诉我如何获得上面指定的数据吗?
@H_301_10@解决方法 新的skool-way:API 17更好更清洁,但仍然太新.List<Cellinfo> cellinfos = (List<Cellinfo>) this.telephonyManager.getAllCellinfo();for(Cellinfo cellinfo : cellinfos){ CellinfoGsm cellinfoGsm = (CellinfoGsm) cellinfo; CellIDentityGsm cellIDentity = cellinfoGsm.getCellIDentity(); CellSignalStrengthGsm cellSignalStrengthGsm = cellinfoGsm.getCellSignalStrength(); Log.d("cell","registered: "+cellinfoGsm.isRegistered()); Log.d("cell",cellIDentity.toString()); Log.d("cell",cellSignalStrengthGsm.toString());}
旧的API不能提供非常令人满意的解决方案.但这是一个古老的方式:
this.telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);this.phonestateListener = setupPhonestateListener();this.telephonyManager.Listen(phonestateListener,PhonestateListener.ListEN_CELL_LOCATION);this.telephonyManager.Listen(phonestateListener,PhonestateListener.ListEN_DATA_CONNECTION_STATE);this.telephonyManager.Listen(phonestateListener,PhonestateListener.ListEN_SIGNAL_STRENGTHS);// This part is used to Listen for propertIEs of the neighboring cellsList<NeighboringCellinfo> neighboringCellinfos = this.telephonyManager.getNeighboringCellinfo();for(NeighboringCellinfo neighboringCellinfo : neighboringCellinfos){ neighboringCellinfo.getCID(); neighboringCellinfo.getLac(); neighboringCellinfo.getPsc(); neighboringCellinfo.getNetworkType(); neighboringCellinfo.getRSSi(); Log.d("cellp",neighboringCellinfo.toString());}public PhonestateListener setupPhonestateListener(){ return new PhonestateListener() { /** Callback invoked when device cell location changes. */ @Suppresslint("NewAPI") public voID onCellLocationChanged(CellLocation location) { GsmCellLocation gsmCellLocation = (GsmCellLocation) location; gsmCellLocation.getCID(); gsmCellLocation.getLac(); gsmCellLocation.getPsc(); Log.d("cellp","registered: "+gsmCellLocation.toString()); } /** invoked when data connection state changes (only way to get the network type) */ public voID onDataConnectionStateChanged(int state,int networkType) { Log.d("cellp","registered: "+networkType); } /** Callback invoked when network signal strengths changes. */ public voID onSignalStrengthsChanged(SignalStrength signalStrength) { Log.d("cellp","registered: "+signalStrength.getGsmSignalStrength()); } };}
>不要忘记设置所有必要的权限
这个解决方案的问题是,我没有得到任何相邻的单元格信息,尽管我设置:
uses-permission androID:name =“androID.permission.ACCESS_COARSE_UPDATES”
(请注意,我使用的是三星手机,这是三星手机不支持相邻手机列表的已知问题)
总结以上是内存溢出为你收集整理的Android:获取Base Station和Neigboring Cells的CellID和RSS全部内容,希望文章能够帮你解决Android:获取Base Station和Neigboring Cells的CellID和RSS所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)