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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:47:23+00:00 2026-05-28T04:47:23+00:00

I have an application that uses AsyncTasks to make calls to a REST server.

  • 0

I have an application that uses AsyncTasks to make calls to a REST server.

Imagine that during a loading period (this is, the AsyncTask going to the REST server and gets data to the next screen) the user presses Home.

What is recommended:

  • Cancel the current AsyncTask(s) and restart when resuming the Activity

or

  • Continue the AsyncTasks but avoiding the startActivity by checking if the app is on background (to avoid the foreground of the new activity after sending the app to background). And onResume sending to the next activity

Worst case scenarios that you should foresee:

  1. The app goes to background and is killed due to lack of memory
  2. The asynctask fails due to timeout or other REST error

After both, the user goes back to the app…

  • 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-05-28T04:47:23+00:00Added an answer on May 28, 2026 at 4:47 am

    Well I ll recommend Service which should use AsyncTask to do its work. Service will insulate your activity from orientation change or user exiting. AsycnTask will insulate from the UI thread being blocked. But do make sure to exit Service when you are done with REST api.

    This will give you best of both. Also if you are not using DB as a local cache then you can try that too. So even if the user goes away, the service will store the fetched data in the DB and when the user comes back you can quickly display the screen.

    EDIT: Just want to add IntentService are easy to implement.

    Try Design Patterns for REST clients on Android by Google for more exhaustive explanation

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

Sidebar

Related Questions

I have an application that uses AsyncTasks to make REST calls to a server.
I have an application that uses SQL Server Express. How to make setup that
I have an application that uses a DLL to make API calls. Is there
I have an application that uses the old REST API call Friends.getAppUsers to get
I have an application that uses a SQL Server database with several instances of
I have an application that uses org.eclipse.jface.preference.FieldEditorPreferencePage in order to create preference pages. During
I have an application that uses MapKit/Internet connection OR CoreLocation to make its job.
I have this application that uses custom methods to register and loggin users using
I have an application that uses sockets to connect to my server. A lot
I have an application that uses NHibernate as its ORM and sometimes it experiences

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.