我看到我们有CDMACellLocation和GSMCellLocation的类,但没有特定的LTE。我可以获得特定于我的电话服务环境的LTE小区位置吗? 谢谢!如何在android中获取LTE小区位置?
5
A
回答
-1
您可以通过getAllCellInfo(返回列表列表迭代),并检查CellInfo是CellInfoLte或不
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfoList = tm.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList)
{
if (cellInfo instanceof CellInfoLte)
{
// cast to CellInfoLte and call all the CellInfoLte methods you need
}
}
+1
这不回答这个问题。一旦你有一个CellInfoLte对象,你如何获得位置信息? – DataDino 2017-06-04 22:00:38
0
这里要小心 - 虽然API可用于小区信息提供一个接口,它真的取决于运营商。与可以提供课程位置信息作为其RADIUS输出的一部分的CDMA不同,LTE随实施而变化。只有LTE网络的“较低”级别知道你可能在哪里,而这最好是模糊的。如果不知道你的运营商的基础设施,他们的MME如何工作等,你可能会得到信息,但我不相信它的地理位置信息。
此外,这取决于您的运营商如何轮询。根据设备配置文件,您可能每分钟轮询一次,每五分钟轮询一次,每两小时轮询一次。如果你在漫游,你可能会得到任何东西,除了垃圾,因为没有很好的价值标准。
0
您可以从LTE连接中获取信息,并对属于CellInfo列表的实例进行特定强制转换。
MobileInfoRecognizer mobileInfoRecognizer = new MobileInfoRecognizer();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfos = tm.getAllCellInfo();
additional_info = mobileInfoRecognizer.getCellInfo(cellInfos.get(0));
在我的应用程序中,我注意到你只能使用列表中的第一个元素;我告诉你我的自定义类:
public class MobileInfoRecognizer {
public String getCellInfo(CellInfo cellInfo) {
String additional_info;
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
CellIdentityGsm cellIdentityGsm = cellInfoGsm.getCellIdentity();
additional_info = "cell identity " + cellIdentityGsm.getCid() + "\n"
+ "Mobile country code " + cellIdentityGsm.getMcc() + "\n"
+ "Mobile network code " + cellIdentityGsm.getMnc() + "\n"
+ "local area " + cellIdentityGsm.getLac() + "\n";
} else if (cellInfo instanceof CellInfoLte) {
CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
additional_info = "cell identity " + cellIdentityLte.getCi() + "\n"
+ "Mobile country code " + cellIdentityLte.getMcc() + "\n"
+ "Mobile network code " + cellIdentityLte.getMnc() + "\n"
+ "physical cell " + cellIdentityLte.getPci() + "\n"
+ "Tracking area code " + cellIdentityLte.getTac() + "\n";
} else if (cellInfo instanceof CellInfoWcdma){
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
additional_info = "cell identity " + cellIdentityWcdma.getCid() + "\n"
+ "Mobile country code " + cellIdentityWcdma.getMcc() + "\n"
+ "Mobile network code " + cellIdentityWcdma.getMnc() + "\n"
+ "local area " + cellIdentityWcdma.getLac() + "\n";
}
return additional_info;
}
}
所以,如果被测设备不支持LTE,可以随时获得有关其连接的其他相关信息。希望你能找到它有用。
相关问题
- 1. 在android中获取位置
- 2. 获取Android小部件的位置
- 3. 如何在Android Studio(TelephonyManager)上获取LTE的eNB ID
- 4. Android获取位置
- 5. 如何从android应用程序小部件获取GPS位置?
- 6. 使用LTE而不是WiFi获取位置数据的问题
- 7. 从CellInfoLte获取位置区号和小区ID
- 8. 如何在iOS应用中获取位置的时区?
- 9. 如何获取文本查询并获取Android中的位置?
- 10. 如何获取当前位置android?
- 11. Android - 如何获取朋友的位置
- 12. 如何在android中捕获小部件位置
- 13. 在Android浏览器中获取位置
- 14. 在android中获取文件位置?
- 15. Android:在ListView中获取位置长按
- 16. 在TableLayout中获取TextView的位置Android
- 17. 在android中获取wifi ip的位置
- 18. 如何在gcmbaseintentservice中获取位置
- 19. 如何在DataGridView中获取CurrentCell位置
- 20. 如何在android应用程序中获取当前位置
- 21. 如何在Android中使用gps获取当前位置?
- 22. 如何在android中获取位置对象
- 23. 如何在android studio xml中获取像素的位置?
- 24. 如何在android中放大后获取视图的xy位置
- 25. 如何在android google maps api V2中获取当前位置?
- 26. 如何在android素材中获取活动标签位置
- 27. 如何在EditText中获取光标位置(x,y)android
- 28. 如何在android 7中获取当前位置?
- 29. 如何在android中获取之字形位置?
- 30. 如何获取位置在Android中更新的时间?
您只能获得API 17中的LTE信息 – 2013-04-25 22:40:20
感谢您的回复!我在API 17上。我想知道的是如何从TelephonyManager的getAllCellInfo()函数返回的arraylist中获取CellInfo的extarct。 – user1985703 2013-04-29 22:20:21