Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:02:47+00:00 2026-06-02T19:02:47+00:00

The goal: Using Google App Engine server and Android client, I’m trying to put

  • 0

The goal:
Using Google App Engine server and Android client, I’m trying to put on the Google map at the Android client Users overlays. Every 30 seconds I’m polling the server and getting Vector that contains users and adding it to the map.

Current status:
I’m dong all that using in one new thread, So after running the app I got:
weird behaviors(delayed overlays, multiple overlays) and after that crushed with ConcurrentModificationException.
After reading a bit i figured out that I need to work with AsyncTask.

Correct me if I’m wrong,But I understand that everything done in the Activity at at onCreate is “running” in UIhread so I need to put the “Logic” (All the Network handling) in doInBackground and all the UI Handling like putting overlays on the map in onPostExecute.

My Question are:
1) In the current status I’m doing:

new Thread()
{
    @Override
    public void run() 
    {           
        super.run();
        while(true)
        {
            SystemClock.sleep(30000);   
            Vector responseFromServer = getUsersVectorFromServer();             
            putNewOnlineUserOnTheMap();
        }           
    }
}.start();

What is the right way to convert this To AsyncTask?
Do I poll the server still using new thread in the doInBackground or there is right way to do this?

2) Is there a specific list of what counts as UI to put in onPostExecute or any concepts list?
In my case I guess that in need to put putNewOnlineUserOnTheMap() in onPostExecute.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:02:52+00:00Added an answer on June 2, 2026 at 7:02 pm

    Something similar to the following:

    class UpdateTask extends AsyncTask<Void, Vector, Void>{
    
        @Override
        protected Void doInBackground(Void... params) {
            // this is running in a background thread.
            while (!isCancelled()) {
                SystemClock.sleep(30000);   
                Vector responseFromServer = getUsersVectorFromServer();
                // send the result back to the UI thread
                // onProgressUpdate will be called then
                publishProgress(responseFromServer);
            }
            return null;
        }
    
        @Override
        protected void onProgressUpdate(Vector... values) {
            // this is executed on the UI thread where we can safely touch UI stuff
            putNewOnlineUserOnTheMap(values[0]);
        }
    
    }
    

    You can’t use the result of the task since the task is finished then. But you can use the progress publishing mechanism to get periodic results. If you use it like that and do the modification on the UI thread you should not get ConcurrentModificationException because you do the modifications on the one thread that can safely modify the UI.

    One thing to note here: create new instances of your Vector in the background thread and then use it to update the UI. But don’t touch the same object afterwards in the backgroundthread. That way you don’t need any synchronization since after the background thread sends it away it is only the UI thread that touches it. (and you could use a simple ArrayList instead of a Vector)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: To render a google map using geolocation. I am trying to implement the
Using Google App Engine (python SDK), I created a custom JSONProperty() as a subclass
Is it possible, using the python version of google app engine, to create a
This pertains to Google App Engine, using Java. (threadsafe in this scenario would be
I'm using Maven GAE plugin with JDO, I started with jappstart example (https://github.com/tleese22/google-app-engine-jappstart/blob/master/pom.xml), but
The goal is to issue the fewest queries to SQL Server using LINQ to
My goal is to deploy a simple rails application on a windows server using
I've started developing a small app which main goal is to draw a map
I have a site that I'm optimizing using Google Website Optimizer where the goal
How can you remove the favicon using Javascript in google chrome? The goal is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.