Я тестирую текущее приложение определения местоположения GPS, используя samsung spica 1.5, но оно не отображает мое текущее местоположение, оно просто показывает мне другое местоположение.
Вот мой код:
public class MaptestActivity extends MapActivity implements LocationListener {
private MapView mapView = null;
private LocationManager lm = null;
private double lat = 0;
private double lng = 0;
private MapController mc = null;
private MyLocationOverlay myLocation = null;
private String current;
private PositionMarkersList positionMarkersList = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) this.findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this);
mc = mapView.getController();
mc.setZoom(15);
myLocation = new MyLocationOverlay(getApplicationContext(), mapView);
myLocation.runOnFirstFix(new Runnable() {
public void run() {
mc.animateTo(myLocation.getMyLocation());
mc.setZoom(17);
}
});
mapView.getOverlays().add(myLocation);
GeoPoint pp=myLocation.getMyLocation();
//addPosition(pp);
if (myLocation.isMyLocationEnabled()!=false)
{
GeoPoint p =myLocation.getMyLocation();
lat= p.getLatitudeE6();
lng= p.getLongitudeE6();
Toast.makeText(getBaseContext(),
"geolocalisation activÈ lat: "+lat+ " long: " +lng,
Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getBaseContext(),
"geolocalisation desactivÈe" ,
Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onResume() {
super.onResume();
myLocation.enableMyLocation();
myLocation.enableCompass();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_S) {
mapView.setSatellite(!mapView.isSatellite());
return true;
}
return super.onKeyDown(keyCode, event);
}
public void onLocationChanged(Location location) {
lat = location.getLatitude();
lng = location.getLongitude();
Toast.makeText(
getBaseContext(),
"Location change to : Latitude = " + lat + " Longitude = "
+ lng, Toast.LENGTH_SHORT).show();
GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
mc.animateTo(p);
mc.setCenter(p);
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
//ajout d'une position
private void addPosition(GeoPoint geoPoint) {
OverlayItem overlayitem = new OverlayItem(geoPoint, current, current);
positionMarkersList.addMarker(overlayitem);
}
}
Кто-нибудь имеет представление об этом, пожалуйста?
Когда я нажимаю «Выполнить», чтобы протестировать приложение, у меня появляется список средств для тестирования (виртуальные устройства ...), но появляется «!» возле названия телефона и я не знаю почему.
Спасибо!