how to calculate distance while walking in android?

前端 未结 7 1405
说谎
说谎 2020-12-04 16:16

I am developing a demo for my app, in which there are two buttons named as \"START\" and \"STOP\". When user taps on \"START\" he will start walking. What I want to do is ma

相关标签:
7条回答
  • 2020-12-04 16:43

    I had gone with the Gps method. With the following steps: On the click of start button, the latitude and longitude of the starting point were fetched and stored it in my dto with a proper TripId.

    on the click of stop button :

    TripDto dto = service.GetStartLatLong(TripIdA);
    double lat = Double.valueOf(dto.getStartLati());
    double lon = Double.valueOf(dto.getStartLongi());
    Location locationa = new Location("point A");
    locationa.setLatitude(lat);
    locationa.setLongitude(lon);
    double distance = location.distanceTo(locationa);
    

    The distance returned by the location.distanceTo() method is in meters.

    0 讨论(0)
提交回复
热议问题