【发布时间】:2012-06-04 15:44:11
【问题描述】:
我正在使用 mapView 和 LocationManager 制作一个小的 Android 应用程序。 我的 LocationManager 应该监听位置并通知我的位置是否超过了用户定义的容差。 如果我的 LocationManager 注意到位置发生变化,它应该发送一条短信。
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, Float.parseFloat(txtToleranz.getText().toString()), this);
这里我不确定 requestLocationUpdates 方法是始终采用文本字段的当前值还是只采用给定的起始值...?
我的应用程序也应该在 mapView 中显示我的位置,但位置完全错误......为什么?我在真实设备上运行我的应用程序。
double lat = location.getLatitude();
double lng = location.getLongitude();
String currentLocation = " Lat: " + lat + " Lng: " + lng + " Tol: " + Toleranz;
point = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
mapController.animateTo(point);
mapController.setZoom(15);
System.out.println(currentLocation);
感谢您的帮助! 最好的问候丹尼尔
【问题讨论】:
标签: android gps location locationmanager