No such instance field: 'mLastLocation' [closed]

0

I have the following code and ale to get to the geoFire.setLocation part ... in the debug it indicates me:

  

No such instance field: 'mLastLocation' No such instance field:   'geoFire'

private void displayLocation() {
    if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)
                    != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    mLastLocation=LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if(mLastLocation != null) {
        if(location_switch.isChecked())
        {
            final double latitude=mLastLocation.getLatitude();
            final double longitude=mLastLocation.getLongitude();
            //update to firebase

            geoFire.setLocation(FirebaseAuth.getInstance().getCurrentUser().getUid(), new GeoLocation(latitude, longitude), new GeoFire.CompletionListener() {
                @Override
                public void onComplete(String key, DatabaseError error) {
                    if(mCurrent!=null)
                    {
                        mCurrent.remove();
                        mCurrent=mMap.addMarker(new MarkerOptions()
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.car))
                        .position(new LatLng(latitude,longitude))
                        .title("Estas Aqui"));

                        // move camera to this position
                       // mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude),15.0f));
                        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude),15.0f));
                        // draw animation rotate marker
                        rotateMarker(mCurrent,-360,mMap);
                    }
                }
            });
        }
    }else
    {
        Log.d("Error EntregasLua","No se pudo obtener tu ubicacion");
    }
}
    
asked by diego 09.02.2018 в 23:08
source

1 answer

1

It seems that you have not declared these two variables: mLastLocation and geoFire

That is, you are calling them to assign the value, but you do not find them declared in the class.

mLastLocation must be of type Location

Location mLastLocation;

geoFire must be of type GeoFire

GeoFire geoFire;

    
answered by 10.02.2018 в 01:49