title: How to move marker when lat long changes in Google map android?
body: <p>in my android application I am receiving the latitude and longitude from <code>JSON</code> and I have pointed it in Google map using marker but I want to move the marker when the latitude and longitude changes like <code>GPS</code> tracking?? Please help me here is my source code,.........</p>
  
  <pre><code> @Override
      protected Boolean doInBackground(String... urls) {
          try {
  
  
              List&lt;Marker&gt; markers = new ArrayList&lt;Marker&gt;();
  
              // Date a = new Date();
              // a.setTime(System.currentTimeMillis()-(60*60*1000));
              // Log.e("onehourback",""+a);*/
              // ------------------&gt;&gt;
              HttpGet httppost = new HttpGet(urls[0]);
              HttpClient httpclient = new DefaultHttpClient();
              HttpResponse response = httpclient.execute(httppost);
  
              // StatusLine stat = response.getStatusLine();
              int status = response.getStatusLine().getStatusCode();
  
              if (status == 200) {
                  HttpEntity entity = response.getEntity();
                  String data = EntityUtils.toString(entity);
                  JSONObject jsono = new JSONObject(data);
                  JSONArray jarray = jsono.getJSONArray("SingleIMEs");
  
                  for (int i = 0; i &lt; jarray.length(); i++) {
                      JSONObject object = jarray.getJSONObject(i);
  
                      // Log.e("object",""+object);
                      /*
                       * try { array.add(jarray.getJSONObject(i));
                       * 
                       * Log.e("array",""+array); } catch (JSONException e) {
                       * e.printStackTrace(); }
                       */
                      latvalue = object.getString("Latitude");
                      longvalue = object.getString("Longitude");
                      latt = Double.parseDouble(latvalue);
                      lng = Double.parseDouble(longvalue);
                      Log.e("lat", "" + latt);
                      Log.e("lon", "" + lng);
  
                      Marker marker1 = mMap.addMarker(new MarkerOptions().position(new LatLng(latt, lng))); 
                      markers.add(marker1);
  
                      Log.e("asdf",";lkj"+markers);
  
                      /*
                       * for(int j=0; j &lt; 1;j++) {
                       * 
                       * 
                       * 
                       * 
                       * }
                       */
                  }
              }
              // }
              return true;
  
              // ------------------&gt;&gt;
  
          } catch (ParseException e1) {
              e1.printStackTrace();
          }
  
          catch (IOException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return false;
      }
  
      protected void onPostExecute(Boolean result) {
          // dialog.cancel();
          if (progressDialog != null &amp;&amp; progressDialog.isShowing()) {
              progressDialog.dismiss();
          }
          /*
           * adapter.notifyDataSetChanged(); if(result == false)
           * Toast.makeText(getActivity().getApplicationContext(),
           * "Unable to fetch data from server", Toast.LENGTH_LONG).show();
           */
      }
  
  }
  
  private void setUpMapIfNeeded(View inflatedView) {
      mMap = ((MapView) inflatedView.findViewById(R.id.mapView)).getMap();
      mMap.addMarker(new MarkerOptions().position(new LatLng(latt, lng))
              .title("WePOP"));
      mMap.setMyLocationEnabled(true);
  
      if (mMap != null) {
          // setUpMap();
          mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
  
              @Override
              public void onMyLocationChange(Location arg0) {
                  // TODO Auto-generated method stub
                  LatLng latLng = new LatLng(arg0.getLatitude(), arg0
                          .getLongitude());
                  mMap.clear();
                  mMap.addMarker(new MarkerOptions()
                  .position(
                          new LatLng(arg0.getLatitude(), arg0
                                  .getLongitude())).title("WePOP"));
  
                  // mMap.addMarker(new
                  // MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)).position(
                  // new LatLng(Double.parseDouble(datas.get("Lat")),
                  // Double.parseDouble(datas.get("Long")))));
                  //mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
                  //mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
  
              }
          });
  
      }
  }
  
  @Override
  public void onResume() {
      super.onResume();
      mMapView.onResume();
  }
  
  @Override
  public void onPause() {
      super.onPause();
      mMapView.onPause();
  }
  
  @Override
  public void onDestroy() {
      mMapView.onDestroy();
      super.onDestroy();
  }
  </code></pre>
  
  <p>}</p>