[英]How to Obtain Latitude and Longitude in Android
如果無法使用GPS,如何從移動設備獲取緯度和經度...我的手機通過wifi和gprs連接建立了互聯網連接。...我們可以從中獲取經度和緯度嗎?
編輯 : 網絡以及GPS提供商位置
是的,我們...嘗試這個
LocationManager manager = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE);
manager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
// additionally (you have to implement LocationListener)
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0.0f, new LocationListener() ...)
定位后,您可以在locationlistener中使用...
@Override
public void onLocationChanged(Location location) {
Log.d("a","onLocationChanged: lat="+location.getLatitude());
Log.d("a","onLocationChanged: lat="+location.getLongitude());
}
希望能幫助到你..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.