在下面的代码中,getCid()、getPsc()、getLac()、GetMnc()、getMcc()都产生相同的值。
在API 17上测试,有权限
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>在java中
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
List<CellInfo> cellinoflist= tm.getAllCellInfo();
for(CellInfo cellinfo : cellinoflist)
{
...
CellInfoGsm GSMinfo = (CellInfoGsm) cellinfo;
CellIdentityGsm gsmCellIdentity= GSMinfo.getCellIdentity();
if(gsmCellIdentity!= null) {
Log.d(TAG, " mCid: "+gsmCellIdentity.getCid()+" mPsc: "+
gsmCellIdentity.getPsc()+" mLac: "+gsmCellIdentity.getLac()+
" mMnc: "+gsmCellIdentity.getMnc()+" mMcc:"+gsmCellIdentity.getMcc());
}
.....
}Logcat
mCid: 2147483647 mPsc: 2147483647 mLac: 2147483647 mMnc: 2147483647 mMcc:2147483647如果我漏掉了什么,请给我提个建议。
发布于 2013-09-24 04:55:52
应该清楚的是,"2147483647“是一个最大的int值。很可能代码有问题,并且值是默认的最大值,而不仅仅是相同的值。
首先,你应该检查:
if(cell instanceof CellIdentityGsm){...在选角之前。除非它只是被遗漏了。
https://stackoverflow.com/questions/17815062
复制相似问题