Hi All, I am trying to get location update and followed some good tutorial. Initially, onLocationChanged was called frequently. But after I made certain simple modification, it started not working today. I am copying my code below. Can anyone let me know the problem? The GPS service is running all the time. I am working on an Atrix phone. Thanks!
package com.summercamp; import java.io.IOException; import java.util.List; import java.util.Locale; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; import com.google.android.maps.MapController; import com.google.android.maps.GeoPoint; import com.google.android.maps.Overlay; import android.os.Bundle; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.widget.Toast; public class GoogleMapsActivity extends MapActivity implements LocationListener { MapView mapView; MapController mc; GeoPoint p; LocationManager lm; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); mapView.setSatellite(true); //mapView.setStreetView(true); mc = mapView.getController(); String provider = null; Toast.makeText(this, "testing...", 3000).show(); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if ( lm.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) { provider = LocationManager.GPS_PROVIDER ; } else { Toast.makeText(this, "GPS not available", 3000).show(); if(lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else { Toast.makeText(this, "Provider Not available", 3000).show(); } } if(provider != null) { Toast.makeText(this, "GPS started!", 3000).show(); lm.removeUpdates(this); lm.requestLocationUpdates(provider, 0, 0, this); } } /* This method is called when use position will get changed */ @Override public void onLocationChanged(Location location) { Toast.makeText(this, "GPS triggered!", 3000).show(); if (location != null) { double lat = location.getLatitude(); double lng = location.getLongitude(); String Text = "Latitud = " + lat + "\nLongitud = " + lng; Toast.makeText(getBaseContext(),Text,Toast.LENGTH_SHORT).show(); } } @Override public void onProviderDisabled(String provider) { // required for interface, not used Toast.makeText(getApplicationContext(),"Gps Disabled",Toast.LENGTH_SHORT).show(); } @Override public void onProviderEnabled(String provider) { // required for interface, not used Toast.makeText(getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // required for interface, not used Toast.makeText(getApplicationContext(),"test",Toast.LENGTH_SHORT).show(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en