Question: On Android Studio in Java, I have two locations from the map and their corrisponding coordinates. I need to find the appoximate amount of time

On Android Studio in Java, I have two locations from the map and their corrisponding coordinates. I need to find the appoximate amount of time in minutes that the user has been traveling between the two locations. I have the following method to calculate time. This method, however, gives a large amount of time when the second location is several hours away from the first location. Hence, I think that the math behind it is wrong. How can I fix this method to give me the right approximate time between two Locations and what is that code?

public String getTimeTaken(Location source, Location dest) { double meter = source.distanceTo(dest); double kms = meter / 1000; double kms_per_min = 0.5; double mins_taken = kms / kms_per_min; int totalMinutes = (int) mins_taken; String a = totalMinutes + " minutes"; return a; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!