title: How to get current location in MAPBOX in android
body: <p>As I am using MAPBOX in my application. I don't know how to get current lat and long. I used this way to get the current location.But its showing null object reference.Please help me to solve my problem</p>
  <pre class="lang-java prettyprint-override"><code>mapView = (MapView)view.findViewById(R.id.mapView);
  mapView.setStyleUrl(Style.MAPBOX_STREETS);
  mapView.onCreate(savedInstanceState);
  
  //Add a mapBoxMap
  mapView.getMapAsync(new OnMapReadyCallback() {
      @Override
      public void onMapReady(MapboxMap mapboxMap) {
          mapboxMap.setMyLocationEnabled(true);
          // Set the origin waypoint to the devices location
          Position origin = Position.fromCoordinates(
              mapboxMap.getMyLocation().getLongitude(),
              mapboxMap.getMyLocation().getLatitude()
          );
  
          Log.i(&quot;RR&quot;,&quot;mapboxMap.getMyLocation();&quot;+origin);
          // Log.i(&quot;RR&quot;,&quot;mapboxMap.getMyLocation();&quot;+mapboxMap.getMyLocation().getLongitude());
          mapboxMap.getUiSettings().setZoomControlsEnabled(true);
          mapboxMap.getUiSettings().setZoomGesturesEnabled(true);
          mapboxMap.getUiSettings().setScrollGesturesEnabled(true);
          mapboxMap.getUiSettings().setAllGesturesEnabled(true);
      }
  });
  </code></pre>