的是Android商店最後的位置,如果是的話是有可能得到最後的位置時,GPS /移動數據/無線網絡連接關閉。我怎麼能在android系統檢索最後位置時,GPS /移動數據/無線網絡連接關閉
0
A
回答
0
該設備的最後一個已知位置提供了一個方便的基礎,以確保該應用在開始定期位置更新之前具有已知位置。
檢查這個環節。其對我們非常有用。
http://www.androidwarriors.com/2015/10/fused-location-provider-in-android.html
+0
這個解決方案不能正常工作,它給空所有的時間 – Shareque
0
你可以使用的LocationManager
LocationManager locationManager = (LocationManager) getSystemService(getApplicationContext().LOCATION_SERVICE);
// default
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, false);//get bese location provider
if (provider != null && !provider.equals(""))
{
//check for permission
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
// Get the location from the given provider
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
String Latitude = "" + location.getLatitude();
String Longitude = "" + location.getLongitude();
}
}
}
您需要權限
相關問題
- 1. 移動網站:在GPS關閉時請求用戶的位置
- 2. 網絡關閉時無法連接到本地數據庫
- 3. 我怎麼能在android系統
- 4. 關閉Wifi和移動網絡位置後,網絡提供商失敗
- 5. 檢查是否啓用了GPS和/或移動網絡位置
- 6. 網絡連接關閉
- 7. 通過公共無線網絡的Android移動到移動套接字連接?
- 8. 無線網絡已連接但未連接到網絡
- 9. 連接到無線網絡
- 10. 如何在Android中關閉wifi配置的無線網絡?
- 11. 我得到的GPS /網絡位置android刪除位置的值
- 12. 爲什麼不關閉數據庫連接在最後的塊
- 13. 位置與關閉互聯網連接
- 14. Fused Location Provider Api當無線網關閉時從GPS獲取位置
- 15. 網絡連接已關閉,但位置提供商爲NetworkProvider
- 16. RecyclerView從最後位置檢索數據
- 17. 如何關閉iPhone互聯網和數據包網絡連接?
- 18. 通過網絡位置顯示GPS Android
- 19. 位置設置關閉時,只能從網絡獲取緯度
- 20. 我怎樣才能在android系統
- 21. 我怎麼能檢查局域網系統的狀態
- 22. 哪裏是關閉數據庫連接的最佳位置?
- 23. Gps(位置)開啓和關閉功能
- 24. 我怎麼能直接連接到在3G移動設備?
- 25. 關閉所有底層網絡連接
- 26. 停止搜索GPS位置android
- 27. windows移動無線網絡
- 28. 檢查網絡連接android
- 29. 檢查網絡連接android
- 30. 當系統連接一段時間後系統出現網絡異常
fusedlocation API –
檢查此鏈接以供參考:HTTPS://developers.google.com/android/參考/ COM /谷歌/安卓/ GMS /位置/ FusedLocationProviderApi – dipali