android:cellid和lac不工作
我正在制作一个应用程序,其中我必须获得lac和手机id。我正在使用android:cellid和lac不工作,android,telephony,Android,Telephony,我正在制作一个应用程序,其中我必须获得lac和手机id。我正在使用 private PhoneStateIntentReceiver mPhoneStateReceiver; ServiceState state = mPhoneStateReceiver.getServiceState(); int cid = state.getCid(); int lac = state.getLac(); 它给出的错误是PhoneStateIntententReceiver无法解析为type和ge
private PhoneStateIntentReceiver mPhoneStateReceiver;
ServiceState state = mPhoneStateReceiver.getServiceState();
int cid = state.getCid();
int lac = state.getLac();
它给出的错误是PhoneStateIntententReceiver无法解析为type和getcellid,getlac也给出了错误是ServiceState的getcellid未定义
如有任何帮助,我们将不胜感激。使用此功能获取cid和Lac
final TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
final GsmCellLocation location = (GsmCellLocation) telephony.getCellLocation();
if (location != null) {
msg.setText("LAC: " + location.getLac() + " CID: " + location.getCid());
}
}
经允许
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Sujit,当我使用lacc=(TextView)findviewbyd(R.id.lacc)时;lacc.setText(location.getLac());//异常android.content.res.Resources$NotFoundExceptionuse lacc.setText(“+location.getLac());因为location.getLac()返回int而不是string。感谢您的帮助,并为此返回+1。Surjit,您知道如何在设备上漫游意味着设备是否处于漫游状态吗?