Cant get the location and address of the user

80 Views Asked by At

[So i have that problem that it gives me an error like:

error: incompatible types: <anonymous LocationCallback> cannot be converted to PendingIntent
                LocationServices.getFusedLocationProviderClient(getActivity()).requestLocationUpdates(locationRequest, new LocationCallback() {

So how can i get over it ? I want to find the address of the user and update it. I have also fragments that i have to write "this" instead of getActivity() but it gives an error each way.]1

1

There are 1 best solutions below

0
On BEST ANSWER

In the photo attached the error is shown because you have not rewritten the code completely you are missing the 3rd parameter looper

your code should be something like

LocationServices.getFusedLocationProviderClient(this).requestLocationUpdates(mLocationRequest, new LocationCallback() {
                    @Override
                    public void onLocationResult(LocationResult locationResult) {
                        //All your code for parsing or extracting data
                    }
                },
                Looper.myLooper());