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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:48:47+00:00 2026-06-11T23:48:47+00:00

I have an activity powered by a FragmentPagerAdapter which adds fragments as the user

  • 0

I have an activity powered by a FragmentPagerAdapter which adds fragments as the user swipes left and right.

This child fragment that is added is currently static and contains a ListView of items. I intend to use and AysncTask to get items for the ListView but this process can take as much as 10-15 seconds.

I’m still lost with a few things:

From which method should my AsyncTask be invoked? Would it be the onCreate method of the Fragment? I’d only like the AsyncTask to be invoked when the Fragment is in focus.

The biggest question however is, what happens to my AysncTask when the user swipes away from the screen while the AsyncTask is loading. Is the Activity destroyed? Is there a way I can prevent the Activity from being destroyed? If I don’t do this, all the progress made by the AsyncTask is lost and I have to reinvoke the AsyncTask when that Fragment comes into focus.

Thanks.


Reason for slowness:

I’m scraping a page with about a 150 records and jSoup is really, really slow. The problem with not using a service is that the data has a high probability of changing and I don’t want to “pre-scrape” the data.

@Fildor suggested using a Loader to do the heavy lifting. A quick look at the Loader implementation showed that allows you persist data across short durations, like orientation change. I’m still wondering whether the ViewPager‘s swing across Fragments would allow the data to persist in the Loader momentarily.

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

    Have you heard about Loaders? I think that is exactly what you want to use …

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

Sidebar

Related Questions

Right now I have a list activity powered by a cursor adapter. I have
I have activity A that starts activity B which starts activity C: A ->
I have activity A where authentication is done. After this user redirected to other
I have an activity that calls the new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes);
I have an Activity named whereActity which has child dialogs as well. Now, I
At this moment I have activity (lview) with list view which use images downloaded
I have two Activity with button, that switch between it Intent intent1=new Intent(Act1.this,Act2.class); startActivity(intent1);
I have Activity that download a file in progress dialog. And when user press
I have Activity with ViewPager that contains several Fragments. I am also using drop-down
I have activity A with a listView, a user clicks on any item which

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.