2

I am trying to implement an app that uses Google Map API, I'm using this deprecated method and it's causing my app to not perform properly. deprecated method is: FusedLocationAPI, any ideas how to replace it in this context? code:

     public void onConnected(@Nullable Bundle bundle) {
    locationRequest = LocationRequest.create();
    locationRequest.setInterval(100);
    locationRequest.setFastestInterval(1000);
    locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(client, locationRequest, this);
    }
}

@Override
public void onConnectionSuspended(int i) {

}

@Override
public void onLocationChanged(Location location) {
    latitude = location.getLatitude();
    longitude = location.getLongitude();
    lastlocation = location;
    if (currentLocationMarker != null) {
        currentLocationMarker.remove();
    }
    Log.d("lat = ", "" + latitude);
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Location");
    markerOptions.snippet("My Present Location");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    currentLocationMarker = mMap.addMarker(markerOptions);
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mMap.animateCamera(CameraUpdateFactory.zoomBy(7));

    if (client != null) {
        LocationServices.FusedLocationApi.removeLocationUpdates(client, this);
    }
}

0 Answers0