[英]Can not retrieve CellID and LAC for the current cell
I tried to retrieve Cid and Lac for currently connected cell, but using 我尝试检索当前连接的单元格的Cid和Lac,但是使用
public void GetCid(){
int CID;
int LAC;
GsmCellLocation xXx = new GsmCellLocation();
CID = xXx.getCid();
LAC = xXx.getLac();
Toast output = Toast.makeText(getApplicationContext(), "Base station LAC is "+LAC+"\n"
+"Base station CID is " +CID, Toast.LENGTH_SHORT);
output.show();
}
The only thing I get is -1 value for both parameters (I am on 2G). 我唯一得到的是两个参数均为-1值(我使用2G)。 May be I do something wrong or there is another way to get Cid and Lac of current cell? 可能是我做错了什么,还是有另一种方法来获取当前单元格的Cid和Lac?
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
CellLocation location = telephonyManager.getCellLocation();
GsmCellLocation gsmLocation = (GsmCellLocation) location;
int cellId = gsmLocation.getCid();
int lac = gsmLocation.getLac();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.