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

  • SEARCH
  • Home
  • 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 8249033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:23:52+00:00 2026-06-07T23:23:52+00:00

I am trying to run AsyncTask every 1 minute, by using handler,but it doesn’t

  • 0

I am trying to run AsyncTask every 1 minute, by using handler,but it doesn’t work:(
In AsyncTask I am reading data from Sqlite DB and drawing result in mapview, aim of doing like that is another service updating my Sqlite every 1 min by taking real data from server and i want keep mapview updated too.
Is there any possible way of calling AsyncTask every minute rather than using Handler?

public Runnable getData; 
        private final Handler _handler = new Handler();
        private static int DATA_INTERVAL = 60 * 1000;
  getData = new Runnable()
            {
                public void run()
                {
                    getDataFrame();
                }

                private void getDataFrame() {
                    // TODO Auto-generated method stub
                     _handler.postDelayed(MapViewActivity.this.getData, DATA_INTERVAL);
                     new DrawFromDataTask();

                }
            };

DrawFromDataTask is described below:
private class DrawFromDataTask extends AsyncTask<Void, Integer, FriendItemizedOverlay> {

            @Override
            protected FriendItemizedOverlay doInBackground(Void... params) {
                // TODO Auto-generated method stub
                mDbAdapter.open();
                List<Refresher> nearFriends = mDbAdapter.getAllRecords();

                for(Refresher friend : nearFriends)
                {
                    double lat = Double.parseDouble(friend.Latitude);
                    double lon = Double.parseDouble(friend.Longitude);
                    OverlayItem item = new OverlayItem(new GeoPoint((int)(lat * 1000000),
                                                                    (int)(lon* 1000000)),
                                                                    "" + friend.name,
                                                                    "" + friend.type);


                    mFriendOverlay.addOverlay(item);
                }

                return mFriendOverlay;
            }

             protected void onProgressUpdate(Integer... progress) {
                 setProgress(progress[0]);
             }

             protected void onPostExecute(FriendItemizedOverlay result) {
                 System.out.println("in AsyncTask execution!");
                 Location loc = get_location();
                    final double mLatitude = loc.getLatitude();
                    final double mLongitude = loc.getLongitude();

                    // get the last location from the database
                    GeoPoint lastLocation = new GeoPoint(
                                     (int) (mLatitude * 1E6),
                                     (int) (mLongitude * 1E6));
                    Drawable marker = getResources().getDrawable(R.drawable.arrow);     
                    int amountOFplayers = result.size()-1;
                    for (int j=0; j<amountOFplayers; j++) {

                        result.getItem(amountOFplayers).setMarker(marker);  

                    }
                    //System.out.println("Number of overlays -- "+amountOFplayers);

                    mMapView.postInvalidate();
                    //mMapView.invalidate();
                    // animate to last location
                    mMapController.animateTo(lastLocation);
                    // zoom to the required level
                    mMapController.setZoom(ZOOM_LEVEL);

             }


         }
  • 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-07T23:23:53+00:00Added an answer on June 7, 2026 at 11:23 pm

    Use the broadcast intent that runs on minute tick and then just execute the Async task. It is more accurate.

    http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK

    Make sure you create new instance every time, since the thread object cannot be reused/relaunched unless you create new instance.

    http://developer.android.com/guide/components/processes-and-threads.html

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

Sidebar

Related Questions

I am trying run a batch file from my java codes, but unfortunately I
I am trying to run to Android code using an AsyncTask . However it
I am trying run a program from a qmake .pro file which modifies the
Trying to run Jison unit tests, but the command fails. How do I fix
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using
Trying to run a simple svn list svn+ssh://... from within jenkins on os X,
Trying to run the reportviewer with passing the parameter but receive error: Validation of
I'm trying to use custom notifications in my Android application using Google's sample from
I am trying to use the AsyncTask class on android but I have a
I'm using an AsyncTask class to add, remove and clear items from my ArrayAdapter

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.