我正在開發一款將Google地圖V2與GPS配合使用的應用。該代碼顯示了獲取用戶位置的緯度和經度的部分。無法在Android中獲取新GPS位置
map.setMyLocationEnabled(true); //Locate the user's current location
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria crit = new Criteria();
String provider = service.getBestProvider(criteria, false);
Location location = service.getLastKnownLocation(provider);
LatLng locationOfUser = new LatLng(location.getLatitude(),location.getLongitude());
該應用程序基本上使用locationOfUser內的值,並可以畫一條線到用戶選擇的標記。但是,當我嘗試從不同位置的應用程序嘗試應用程序的藍色標記指示用戶的當前位置更改,但locationOfUser內的值沒有,並從最後一個位置,而不是當前位置畫線。
謝謝。
感謝您的回答,我將不得不稍後再檢查,看看這是否會工作 – user1832478 2013-04-06 15:15:47