更新时间:2023-02-18 23:02:24
一些答案:
访问: 看到 LocationManager 和的 LocationListener的。
权限:android.permission.ACCESS_FINE_LOCATION
Permissions: android.permission.ACCESS_FINE_LOCATION
演示:
public class GPSLocationManager implements LocationObservable {
private static final long INTERVAL = 10*1000;
private LocationManager locationManager;
public GPSLocationManager(LocationManager locationManager) {
this.locationManager = locationManager;
}
public void requestLocationUpdates(LocationListener locationListener) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
INTERVAL,
0, locationListener);
}
public void removeUpdates(LocationListener locationListener) {
locationManager.removeUpdates(locationListener);
}
}