Distance calculation

I’m developing a Driver app in Android. In the app, I need to show the distance travelled lively while the car is moving. I tried Android’s location API, but I’m unable to calculate the distance accurately. Is it possible to do this with Graphhopper?

Can iterate over route instructions list and retrieve the distance of each route part (see GraphHopper documentation).

Could you please help me by providing an android implementation or sample for this?