title: How to show my current location in Google Maps Android using google API client
body: <p>Hi i am new for android and in my app i want to show my current location using GoogleApi client and for this i wrote below code but current location is not showing </p>
  
  <p>Map is shows like my below screen shot</p>
  
  <p>Can some one help me please what is problem?</p>
  
  <h2>Activity:-</h2>
  
  <pre><code>public class GoogleApiClientClass extends AppCompatActivity implements
          OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener,
          LocationListener {
  
      LocationRequest mLocationRequest;
      GoogleApiClient mGoogleApiClient;
  
      LatLng latLng;
      GoogleMap mGoogleMap;
      SupportMapFragment mFragment;
      Marker currLocationMarker;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.maps_layout);
  
          mFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
          mFragment.getMapAsync(this);
      }
  
      @Override
      public void onMapReady(GoogleMap gMap) {
          mGoogleMap = gMap;
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
              return;
          }
          mGoogleMap.setMyLocationEnabled(true);
          buildGoogleApiClient();
          mGoogleApiClient.connect();
      }
  
      protected synchronized void buildGoogleApiClient() {
          Toast.makeText(this, "buildGoogleApiClient", Toast.LENGTH_SHORT).show();
          mGoogleApiClient = new GoogleApiClient.Builder(this)
                  .addConnectionCallbacks(this)
                  .addOnConnectionFailedListener(this)
                  .addApi(LocationServices.API)
                  .build();
      }
  
      @Override
      public void onConnected(Bundle bundle) {
  
          Toast.makeText(this, "onConnected", Toast.LENGTH_SHORT).show();
          if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
              return;
          }
          Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                  mGoogleApiClient);
          if (mLastLocation != null) {
              //place marker at current position
              //mGoogleMap.clear();
              latLng = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
              MarkerOptions markerOptions = new MarkerOptions();
              markerOptions.position(latLng);
              markerOptions.title("Current Position");
              markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
              currLocationMarker = mGoogleMap.addMarker(markerOptions);
          }
  
          mLocationRequest = new LocationRequest();
          mLocationRequest.setInterval(5000); //5 seconds
          mLocationRequest.setFastestInterval(3000); //3 seconds
          mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
          //mLocationRequest.setSmallestDisplacement(0.1F); //1/10 meter
          LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
      }
  
      @Override
      public void onConnectionSuspended(int i) {
          Toast.makeText(this,"onConnectionSuspended",Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onConnectionFailed(ConnectionResult connectionResult) {
          Toast.makeText(this,"onConnectionFailed",Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onLocationChanged(Location location) {
  
          //place marker at current position
          //mGoogleMap.clear();
          if (currLocationMarker != null) {
              currLocationMarker.remove();
          }
          latLng = new LatLng(location.getLatitude(), location.getLongitude());
          MarkerOptions markerOptions = new MarkerOptions();
          markerOptions.position(latLng);
          markerOptions.title("Current Position");
          markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
          currLocationMarker = mGoogleMap.addMarker(markerOptions);
  
          Toast.makeText(this,"Location Changed",Toast.LENGTH_SHORT).show();
  
          //zoom to current position:
          CameraPosition cameraPosition = new CameraPosition.Builder()
                  .target(latLng).zoom(14).build();
  
          mGoogleMap.animateCamera(CameraUpdateFactory
                  .newCameraPosition(cameraPosition));
          //If you only need one location, unregister the listener
          //LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
      }
  }
  </code></pre>
  
  <h2>manifest:-</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest package="com.androidtutorialpoint.googlemapsdrawroute"
            xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;permission
          android:name="in.wptrafficanalyzer.locationpolyline.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/&gt;
  
      &lt;uses-permission android:name="in.wptrafficanalyzer.locationpolyline.permission.MAPS_RECEIVE"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity
              android:name=".GoogleApiClientClass"
              android:label="@string/title_activity_maps"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;!--Testing Key--&gt;
          &lt;meta-data
              android:name="com.google.android.geo.API_KEY"
              android:value="my key" /&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <h2>screen:-</h2>
  
  <p><a href="https://i.stack.imgur.com/aRMs5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aRMs5.png" alt="enter image description here"></a></p>