我还有一个关于基本 Android 编程的问题:
如何访问 GPS 来获取运行应用程序的手机的当前位置?检索信息需要多长时间? 在这种情况下,GPS 可能被禁用,如何再次启用/禁用它。
必须在 andorid list 中授予哪些权限?
问候并感谢您的回答,
Poeschron
最佳答案
一些答案:
访问: 请参阅LocationManager和 LocationListener .
权限: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);
}
}
关于java - 使用 GPS 获取 Android 手机的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2651499/