我試圖獲得位置管理器中的活動工作在我的Android應用程序,但它不斷給我的錯誤「無法解析方法requestLocationUpdates」的Android的LocationManager - 不能解析方法
我把這個代碼我的OnCreate(其他例子中):
// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
我想用我自己的「OnLocationChanged」方法來更新與用戶位置的地圖,但我不明白,爲什麼我得到這個錯誤。
任何想法,爲什麼我得到錯誤?
有更好的更現代的方式來實現位置更新嗎?
謝謝!
酷感謝靈光,你把正確的方向。我發現這個例子:http://stackoverflow.com/a/25173057/2063149 – Pabs 2014-10-04 18:21:38