android 获取手机cid,android中获取lac和cid的方法

直接上代码

TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

// 返回值MCC + MNC

String operator = mTelephonyManager.getNetworkOperator();

int mcc = Integer.parseInt(operator.substring(0, 3));

int mnc = Integer.parseInt(operator.substring(3));

// 中国移动和中国联通获取LAC、CID的方式

GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();

int lac = location.getLac();

int cellId = location.getCid();

Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);

在log信息中就可以看到获取到的lac和cid的值,最后不要忘了在

AndroidManifest.xml添加获取位置信息的权限


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部