I am trying to draw user's live path on google map as he starts moving from his current location. I am using google map API V2 to achieve my goal.
I am able to get user's current location at certain interval of time using GPS and Network providers but the location provided by these providers are not accurate.
So the path that's drawn over map is not accurate too. Is there any other approach to draw user's live path on map which I am missing or not aware of then please let me know. I am completely stuck here with this thing.
I am using below code to get users current location.
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
locationManager.requestLocationUpdates(MIN_TIME_INTERVAL_IN_MILLIS, MIN_DISTANCE_INTERVAL_IN_METERS, criteria, this, null);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME_INTERVAL_IN_MILLIS,
MIN_DISTANCE_INTERVAL_IN_METERS, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_INTERVAL_IN_MILLIS,
MIN_DISTANCE_INTERVAL_IN_METERS, this);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationManager.requestLocationUpdates(MIN_TIME_INTERVAL_IN_MILLIS, MIN_DISTANCE_INTERVAL_IN_METERS, criteria, this, null);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME_INTERVAL_IN_MILLIS,
MIN_DISTANCE_INTERVAL_IN_METERS, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_INTERVAL_IN_MILLIS,
MIN_DISTANCE_INTERVAL_IN_METERS, this);
}
I have searched for SO questions but all question are related to draw path between two known location.