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");
}
}