Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)anddev.org • View topic - Calc distance between to Coords

I'm an absolute android newb, so I'm sorry for asking such a dumb question...

I've read the friendsfinder-tutorial and I have to be honest... I can't reproduce the distance calculation.

I have two coords with latitude and longitude and I want to calculate the distance between them. I've also read the solution by calculating it myself instead of using distanceTo or distanceBetween. It didn't work for me because it gave me a distance of two meters instead of about 3000m.

My Coords look like that:

double lat1 = 123.456; double lng1 = 12.345;

double lat2 = 124.567; double lng2 = 13.456;

I would prefer distanceTo but I can't figure out how to generate a new Location object by using my coords for that.

You shouldn't need a Location object. You could just use Location.distanceBetween(...);That should work fine.

If you do need one, the easiest way to get a location object would be:LocationManager lm = this.getSystemService(Context.LOCATION_SERVICE);Criteria crit = new Criteria();crit.setAccuracy(Criteria.ACCURACY_FINE);String provider = lm.getBestProvider(crit, true);Location loc = lm.getLastKnownLocation(provider);

All this should be unnecessary though as like I said, you should be ablt to just type Location.distanceBetween(...);

distanceBetween() returns a float ARRAY. That means that you will have to access each element by its index. The float array returned by the distanceBetween() method contains anywhere from 1 to 3 elements.The computed distance is stored in results[0]. If results has length 2 or greater, the initial bearing is stored in results[1]. If results has length 3 or greater, the final bearing is stored in results[2].

Basically, you only really care about results[0], so to convert that to a string, just do this:String dist_string = Float.toString(dist[0]);