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 8746969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:16:46+00:00 2026-06-13T12:16:46+00:00

How does one create an AsyncTask which keeps running itself after a fixed interval

  • 0

How does one create an AsyncTask which keeps running itself after a fixed interval of time.

For eg. get data from server every 5 minutes and give notification to caller thread that it has received the data. I searched on the forum but could not find much. What I have gathered so far is that

1) A UI thread will call AsyncTask

2) onPrExecute for UI thread access before executing

3) OnPostExecute for UI thread access after executing

I dont need to show any progress update to the user. Also, the task will be destroyed when the app closes. Any tutorial for this will he helpful

  • 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-13T12:16:47+00:00Added an answer on June 13, 2026 at 12:16 pm

    As other suggested in the comments. So let me elaborate it more.

    DON’T USE AsyncTask. INSTEAD GO FOR IntentService ONLY.

    1. Make a class extends IntentService
    2. Use Alarm Manager to trigger a intent to your own service with specific action item
    3. Define a Interface to be used to notify client of this service.
    4. Maintain a list of these interface implemenation object provided by its client.
    5. in onHandleIntent(Intent intent) identify the call by checking action.
    6. Initiate the data fetch request directly on intentService as the use worker thread to work and in the end call update delegate of the interface object list you maintained.

    7. Make methods to Let Activity register and unregister from listening these updates.

    8. Which is actually adding the interface implementation provided by them in the list you maintained and remove from it when unregister gets called.
    9. make sure activity register itself in onResume and unregister itself in the onPause.
    10. Either use Repeating alarm or initiate one again in the end of single operation run.
      I hope it helps 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one create a java.security.cert.X509Certificate instance from a PEM-formatted String? The PEM-formatted String
How does one create an administrative network share [1] with read-only permissions from C/C++
How does one create date/time ranges for TIMESTAMP WITH TIMEZONE timestamps with a range
How does one create Dynamic CSS and JavaScript On-The-Fly (using PHP). This needs to
How does one create a package for a Java Project through the Unix command-line?
Does startService() create a new Service instance or using the existing one? For example,
How does one create a POST request using TCPSocket in Ruby? Is there a
I have an android application which in its main activity, data are adapted from
My main application does this: It retrievs data from the internet and has 3
I have a custom DownloadFiles class which extends AsyncTask . The app launches itself

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.