我看到我們有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