here is part of my code :
Using java Syntax Highlighting
- public class geoSwitcher extends MapActivity implements LocationListener {
- /** Called when the activity is first created. */
- // ===========================================================
- // Fields
- // ===========================================================
- private MapView myMapView;
- private MapController mc;
- private LocationManager locationManager;
- private LocationListener locationListener;
- List<Overlay> mapOverlays;
- Drawable drawable;
- geoSwitcherItemizedOverlay itemizedOverlay;
- boolean clickable = true;
- boolean enabled = true;
- boolean satOn = false;
- boolean zoomOn = true;
- boolean moving = false;
- long startTime;
- long endTime;
- public boolean debugState = false;
- public GeoPoint p;
- public GeoPoint pMe;
- public GeoPoint pUp;
- public GeoPoint pDown;
- public double myLat = 40.689213;
- public double myLong = -74.044558;
- private TextView input;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
- String provider = LocationManager.GPS_PROVIDER;
- LinearLayout layout = (LinearLayout) findViewById(R.id.map_view);
- myMapView = new MapView(this,"xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
- // Lets start at the Statue of Liberty
- // I grabbed the data from Google-Maps
- p = new GeoPoint((int) (myLat * 1000000),
- (int) (myLong * 1000000));
- // Get the controller, that is used for translation and zooming
- LayoutParams layoutParams = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, p, 0);
- myMapView.setLayoutParams(layoutParams);
- myMapView.setClickable(clickable);
- myMapView.setEnabled(enabled);
- // Make myMapView the exilicit view of this app
- // Enable Sattelite-Mode, so we will se the
- // Statue of liberty instantly on the screen
- myMapView.setSatellite(satOn);
- myMapView.setBuiltInZoomControls(zoomOn);
- layout.addView(myMapView);
- MapController mc = myMapView.getController();
- // Translate to the Statue of Liberty
- mc.animateTo(p);
- mc.setZoom(17);
- input = (TextView) findViewById(R.id.lat);
- input.setText(String.valueOf(myLat));
- input = (TextView) findViewById(R.id.lng);
- input.setText(String.valueOf(myLong));
- }
- @Override
- public void onResume() {
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30000, 0, this);
- Log.v("location ","resume");
- super.onResume();
- }
- @Override
- public void onPause() {
- locationManager.removeUpdates(this);
- Log.v("location ","pause");
- super.onPause();
- }
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.options_menu, menu);
- return true;
- }
- @Override
- protected boolean isRouteDisplayed() {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public void onLocationChanged(Location loc) {
- if (loc != null) {
- myLat = loc.getLatitude();
- myLong = loc.getLongitude();
- Log.v("location ","changed to Lat: " + loc.getLatitude() +
- " Lng: " + loc.getLongitude());
- Toast.makeText(geoSwitcher.this,
- "Location changed : Lat: " + loc.getLatitude() +
- " Lng: " + loc.getLongitude(),
- Toast.LENGTH_SHORT).show();
- TextView input = (TextView) findViewById(R.id.lat);
- input.setText(String.valueOf(myLat));
- input = (TextView) findViewById(R.id.lng);
- input.setText(String.valueOf(myLong));
- }
- else
- {
- Log.v("location ","not changed");
- }
- }
- @Override
- public void onProviderDisabled(String provider) {
- // TODO Auto-generated method stub
- Log.v("location ","provider off: "+provider.toString());
- }
- @Override
- public void onProviderEnabled(String provider) {
- Log.v("location ","provider on: "+provider.toString());
- // TODO Auto-generated method stub
- }
- @Override
- public void onStatusChanged(String provider, int status,
- Bundle extras) {
- // TODO Auto-generated method stub
- Log.v("location ","status changed "+provider.toString()+" status "+status);
- }
- }
Parsed in 0.048 seconds, using GeSHi 1.0.8.4
when i use telnet to send geo fix position i can see firt one... but after that, all other geo fix i send (new position) is not detected ...
i'm using emulator with android 1.5
any idea how to solve this?
regards,

