无法获取用户的位置和地址

Cant get the location and address of the user

[所以我有一个问题,它给我一个错误,如:

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

那么我怎样才能克服呢?我想找到用户的地址并更新它。我还有一些片段,我必须写“this”而不是 getActivity(),但它会以各种方式给出错误。]1

在所附的照片中显示了错误,因为您没有完全重写代码您缺少第 3 个参数 looper

您的代码应该类似于

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