I have stored location into firebase as latitude and longitude. now i want to fetch the value of those and with help of that, car marker should be animated like car moving. so i did car marker animation. but it will show only for current location. i want for firebase location it should show animate.
Below method i am getting latitude longitude from firebase for that specific user
private void getUserLocation() {
loc.child(uid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Locations locations = dataSnapshot.getValue(Locations.class);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
Each time onLocationChanged method called but it is retrieving current location only. i want firebase retrieved location should be changed
@Override
public void onLocationChanged(Location currentL) {
mLastLocation = currentL;
displayLocation();
}
public void displayLocation() {
try {
if (ActivityCompat.checkSelfPermission(context,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(context,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// Check Permissions Now
ActivityCompat.requestPermissions(LocationTracking.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
REQUEST_LOCATION);
} else {
if (mLastLocation != null && mLastLocation.getLongitude() != 0.0 && mLastLocation.getLongitude() != 0.0) {
if (mMap != null) {
addMarker(mMap, mLastLocation.getLatitude(), mLastLocation.getLongitude());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
now car is not at all moving.please guide me