Location.distanceBetween Error !?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Location.distanceBetween Error !?

Postby pabmadi » Thu Apr 08, 2010 9:35 pm

Hi, I'm building an App that 2 GPS location and calculate the distance between them... I have almost done, but when I try use the function Location.distanceBetween I always get and error

I have the fisrt point in From variable (location type) and the second in To variable. Both varibles works fine when I use it to write the Latitude & Longitude

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. float[] results = null;
  3.  
  4.  
  5.  
  6. Location.distanceBetween(From.getLatitude(), From.getLongitude(), To.getLatitude(), To.getLongitude(), results);
  7.  
  8.  
  9.  
  10.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Whats wrong with my code?
And ... Soppose we can fix it... How I read the result Array to display it?

Thanks!!!
pabmadi
Junior Developer
Junior Developer
 
Posts: 19
Joined: Thu Apr 08, 2010 9:25 pm

Top

Postby pabmadi » Mon Apr 12, 2010 2:54 pm

Solved:

You need to initialize the array in this way:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public float[] results = new float[4];
  2.  
  3.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Bye.-
pabmadi
Junior Developer
Junior Developer
 
Posts: 19
Joined: Thu Apr 08, 2010 9:25 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests