draw a route in android maps
In the following code:
if(c.moveToFirst())
{
do{
longitude=Integer.parseInt(c.getString(0));
latitude=Integer.parseInt(c.getString(1));
p = new GeoPoint(latitude,longitude);
geoPointsArray.add(p);
theRouteDraw();
}while(c.moveToNext());
}
Where c is cursor obtained form a database where I have stored GPS data (longitude,latitude)
Cursor c=db.getAllData();
And:
theRouteDraw(); is a method开发者_开发技巧 that draws a line between two GPS points.
In the way I proceeded above in my geoPointsArray[] I have all this points and then
I pass it to theRouteDraw(); where the line between this points is drawn instantly!!!!
Now I wanna set a delay in the above code in order to put a point in geoPointsArray[] and call theRouteDraw().......the line to be drawn step by step
If I don't use a delay my app gets blocked for a while(not FC) until the line is drawn......cause it gets to manyy points which need to be connected on the map!!
Any idea how to do that?????????????????
You should use a separate thread to perform the theRouteDraw()
function: see the AsyncTask
class and examples (such as http://labs.makemachine.net/2010/05/android-asynctask-example/) for how to do that.
This will prevent your app from blocking.
精彩评论