Hi All,

One of the methods in my Android App is named locationSubmit().
It:
  -- obtains gps coords,
  -- sends the coords to a (Tomcat) server with a web services call,
  -- receives back a collection of points in the return from the
server,
  -- plots these points on a map, with a recentering of the map

This all works fine when I drive it with clicks from the keyboard (I
happen
to use Z) -- I can see the appropriate updates to the points with each
Z click.

However, I now want to run locationSubmit() periodically under the
control
of a TimerTask.  When I do, the mapping process appears to freeze
although
everything else seems to keep going.  Here is the simple timer task
and
startup (I run it with samplingPeriod=15000; ie, 15 seconds):

private void startTimer(long samplingPeriod)
{
         _lbsTimer = new Timer(false);
         _lbsTimer.schedule(new LBSUpdateTask(), new Date(),
samplingPeriod);
}

protected class LBSUpdateTask extends TimerTask
{
        protected LBSUpdateTask() { }
        public void run()
        {
                locationSubmit();
        }
}

The first execution of locationSubmit() under timer control almost
works
correctly:  The points are plotted, but the map is not recentered.
And from this point on, the map does not change at all, while the
timer
keeps functioning.  However, from observing the server,
I can see that the correct calls are arriving at the
server from the Android client, and the correct returns are being sent
back.
Also, if I run my Android app under the debugger, I can see that it
is receiving the values from the server, and stepping through the code
as exepected, but
not updating the overlay like it does when I drive it with keyboard
clicks.

The basic outline of locationSubmit() is this:

private void locationSubmit()
{
  try{
    URL url = new URL(getNextLocnURL());
    URLConnection urlconn = url.openConnection();
    ....
    Document doc = null;
    try{
        DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        urlconn.getInputStream();
        InputStream istream = urlconn.getInputStream();
        doc = db.parse(istream);
             // extract info from doc and add it to an instance
variable
             // visible to _mapView below:
        _mapView.invalidate();
    } catch (Exception e){ }
}

The value of MapView _mapView is set in onCreate to _mapView = new
MapView(this);
There is a simple class MyAppOverlay which extends Overlay, and plots
the
points using draw(...) when _mapView is invalidated.

Have I missed something here?
Thanks in advance,
Ken Bowen


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to