Update the Google Map after Device moves from one place to another in android
<p>I am developing an Android App with Google Map which shows your Current location with the Help of your GPS to find the current Lat and Long. and it gets updated means Google map shows updated Lat and Long whenever Device moves to another place. I have implemented onLocationChanged method for the same but it doesn't work for me. The main crux of the App is Whenever Lat and Long changed while user uses the app, then Google Map gets updated and Market should show the current Lat and Long whereever device placed.</p>

<p><strong>My Code:</strong></p>

<pre><code>package com.FindLocation;

import java.util.List;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;


public class GoogleMapActivity extends MapActivity implements LocationListener{

     private MapController mc;
    private GeoPoint geoPoint;
    Bundle bundle;
    Double[] coordinates;
    Drawable userPic;
    private boolean gps_enabled = false;
    private boolean network_enabled = false;
    boolean network_GPS_failure= false;
    LocationManager mlocManager;
    Location recentLoc;
    MyLocationListner mlocListener;
    Double[] locValues;
    MapView mapView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_google_map);

        bundle = getIntent().getExtras();
        mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        mlocListener = new MyLocationListner();
        mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
        locValues = new Double[2];
        mapView = (MapView) findViewById(R.id.mapView);

        mc = mapView.getController();
      /*  if(bundle.getDouble("LAT")==0)
        {
            coordinates = new Double[]{(double) 30, (double) 79};
        }

        else
        {
            coordinates[0] = Double.parseDouble(bundle.getString("LAT"));
            coordinates[1] = Double.parseDouble(bundle.getString("LONG"));
        }*/


      getValuesOnMap();
       /* userPic = this.getResources().getDrawable(R.drawable.marker);
        userPicOverlay = new MyItemizedOverlay(userPic);
        OverlayItem overlayItem = new OverlayItem(geoPoint, "I'm Here!!!", null);
        userPicOverlay.addOverlay(overlayItem);
        mapview.getOverlays().add(userPicOverlay);*/
        //mapView.setSatellite(true); // Satellite View
        //mapView.setStreetView(true); // Street View
        //mapView.setTraffic(true); // Traffic View

       /* MapController mc = mapView.getController();
        double lat = Double.parseDouble("48.85827758964043"); // latitude
        double lon = Double.parseDouble("2.294543981552124"); // longitude
        GeoPoint geoPoint = new GeoPoint((int)(lat * 1E6), (int)(lon * 1E6));
        mc.animateTo(geoPoint);
        mc.setZoom(15);
        mapView.invalidate();

        *//**
         * Placing Marker
         * */

      /*  List&lt;Overlay&gt; mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
        AddItemizedOverlay itemizedOverlay = 
             new AddItemizedOverlay(drawable, this);


        OverlayItem overlayitem = new OverlayItem(geoPoint, "Hello", "Sample Overlay item");

        itemizedOverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedOverlay);*/


    }

    private void getValuesOnMap() {
        // TODO Auto-generated method stub
          final ProgressDialog dialog = ProgressDialog.show(GoogleMapActivity.this, "Find Location       ", "Please Wait...   ", true);

        final Handler handler = new Handler() {

            public void handleMessage(Message msg) {

                //  System.out.println("The id after Save:"+id.get(0).toString());

                //catagory.addAll(keyword_vector1);
                //if(network_GPS_failure==false)
                //{
                    if (mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                        if(MyLocationListner.latitude&gt;0)
                        {
                            /*//sendSMS("701010", zipcode.toString());

                            Intent intent = new Intent(GoogleMapActivity.this, GoogleMapActivity.class);
                            intent.putExtra("LAT", String.valueOf(MyLocationListner.latitude));
                            intent.putExtra("LONG", String.valueOf(MyLocationListner.longitude));
                            startActivity(intent);*/
                              double lat = MyLocationListner.latitude;
                                double lng = MyLocationListner.longitude;


                                GeoPoint p = new GeoPoint(
                                (int) (lat * 1E6),
                                (int) (lng * 1E6));

                               mc.animateTo(p);
                                mc.setZoom(8);
                                mapView.invalidate();
                                mapView.setBuiltInZoomControls(true);
                              MyLocationOverlay myLocationOverlay = new MyLocationOverlay(GoogleMapActivity.this, mapView);
                            mapView.getOverlays().add(myLocationOverlay);
                            myLocationOverlay.enableCompass(); // if you want to display a compass also
                            myLocationOverlay.enableMyLocation();
                        }
                        else
                        {
                            System.out.println("=============================");
                        }
                    } else {
                        // tv_Lat.setText("GPS is not turned On");
                        Toast.makeText(GoogleMapActivity.this, "Gps is not turned On", Toast.LENGTH_SHORT).show();
                    }

                /*}else
                {
                    AlertDialog.Builder builder = new Builder(FindLocationActivity.this);
                    builder.setTitle("Attention!");
                    builder.setMessage("Sorry, location is not determined. Please enable location providers");
                    builder.setPositiveButton("OK", null);
                    builder.setNegativeButton("Cancel", null);
                    builder.create().show();
                }*/
                dialog.dismiss();
                                        }
        };

        final Thread checkUpdate = new Thread() {

            public void run() {
                try {
                    gps_enabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
                } catch (Exception ex) {
                }
                try {
                    network_enabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
                } catch (Exception ex) {
                }

                // don't start listeners if no provider is enabled
                if (!gps_enabled || !network_enabled) {

                    network_GPS_failure=true;
                    handler.sendEmptyMessage(0);
                }
                else{

                if (gps_enabled) {
                    mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, mlocListener);
                }
                if (network_enabled) {
                    mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 0, mlocListener);
                }


                /*  GPSUtil util = new GPSUtil();
                    locValues = util.getLocation(FindLocationActivity.this);*/




                handler.postDelayed(null, 5000);
                }
            }

        };
        checkUpdate.start();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_google_map, menu);
        return true;
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub
        getValuesOnMap();
    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }
}
</code></pre>
