title: Google map update current location every second
body: <p>Hello stackoferflow users.</p>
  
  <p>I am developing android App and this app implement <code>Google Play Service</code></p>
  
  <p>I already get my location and set a pin and also a circle on my maps.</p>
  
  <p>What i want to achieve is whenever i move to someplace, the circle will also move and put my position as the <strong>center</strong> location.</p>
  
  <p><strong>My question is :</strong></p>
  
  <ol>
  <li><p>How to update my current location every 2-5 second and the circle will also move to my new current location</p></li>
  <li><p>How to set my circle area as an area where the marker will place, so if the marker not in the area of my circle, it will not shown on the map.</p></li>
  </ol>
  
  <p>Thank you</p>
  
  <p>This is my code that i use for maps:</p>
  
  <pre><code>    mMap.setMyLocationEnabled(true);
      mMap.getUiSettings().setCompassEnabled(true);
      mMap.getUiSettings().setMyLocationButtonEnabled(true);
      mMap.getUiSettings().setRotateGesturesEnabled(true);
  
      locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
      locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
      // Creating a criteria object to retrieve provider
      Criteria criteria = new Criteria();
  
      // Getting the name of the best provider
      String provider = locationManager.getBestProvider(criteria, true);
  
      // Getting Current Location
      Location location = locationManager.getLastKnownLocation(provider);
  
      mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
  
          @Override
          public View getInfoWindow(Marker arg0) {
              return null;
          }
  
          @Override
          public View getInfoContents(Marker marker) {
              View v = getLayoutInflater().inflate(R.layout.marker, null);
              TextView title= (TextView) v.findViewById(R.id.title);
              TextView info= (TextView) v.findViewById(R.id.info);
              title.setText(marker.getTitle().toString());
              info.setText(marker.getSnippet().toString());
              return v;
          }
      });
  
      if(location != null){
          double latitude = location.getLatitude();
          double longitude = location.getLongitude();
          myPosition = new LatLng(latitude, longitude);   
  
          CameraUpdate center = CameraUpdateFactory.newLatLngZoom(myPosition, 15);
          mMap.moveCamera(center);
          mMap.addMarker(new MarkerOptions()
              .position(myPosition)
              .alpha(0.8f)
              .anchor(0.0f, 1.0f)
              .icon(BitmapDescriptorFactory.fromResource(R.drawable.blue_pin))
              .title("Your position :\n ")
              .snippet(latitude + " and " + longitude));
  
          CircleOptions circleOptions = new CircleOptions()
            .center(myPosition)   //set center
            .radius(rad)   //set radius in meters
            .fillColor(0x402092fd)  //default
            .strokeColor(Color.LTGRAY)
            .strokeWidth(5);
            circle = mMap.addCircle(circleOptions);   
  
            CameraPosition cameraPosition = CameraPosition.builder()
                    .target(myPosition)
                    .zoom(15)
                    .bearing(90)
                    .build();
  
           mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),2000, null);
      }
  </code></pre>
  
  <p>Thank you =)</p>