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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:42:49+00:00 2026-06-16T03:42:49+00:00

So.. What I have is as follows, a complicated fragment based viewpager utilizing tabhosts

  • 0

So..

What I have is as follows, a complicated fragment based viewpager utilizing tabhosts etc with my activity. This is the basic setup.

Once this has been created, I use an AsyncTask to get some data from my database. When the ASyncTask is complete i find the respective fragments of the viewpager using the fragmentmanager and call functions within each fragment that set the data. For example, in fragment A the data is set as a list within a list adapter, and in fragment B the data is plotted on a map.

I have set it up this way as all the fragments use the same data, and I only want to have to call one ASyncTask. It works perfectly.

My problem is when a user rotates the screen whilst it is loading. So calling an ASyncTask from a fragment you can use setRetainInstance, and previously within an activity you could use onRetainNoneConfigurationInstance.. but that is now deprecated.

I have spent ages searching and no-one seems to have an answer for this specific situation..

Can anyone advise?

  • 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-16T03:42:51+00:00Added an answer on June 16, 2026 at 3:42 am

    You can use an invisible Fragment to retain your state. It’s essentially the same as onRetainNoneConfigurationInstance but not deprecated.

    see http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html#config-changes

    There is a bug in the example and you have to add the RetainFragment to the FragmentManager or it’s not going to be restored.

    public static RetainFragment findOrCreateRetainFragment(FragmentManager fm) {
        RetainFragment fragment = (RetainFragment) fm.findFragmentByTag(TAG);
        if (fragment == null) {
            fragment = new RetainFragment();
            fm.beginTransaction().add(fragment, TAG).commit(); // add this
        }
        return fragment;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our setup as follows: We have a local development server running Ubuntu, with a
I have exercise below: The Lavin Interactive Company, which has developed the turn-based strategy
I have data that follows this kind of patten: ID Name1 Name2 Name3 Name4
I have a page that loads a complicated set of forms. In this set
I have this table services , with data as follows: service_id bepro_id service_name 1
Maybe this is very basic, but I am all confused. I have a simple
I have xml as follows <Search> <Term /> <And /> <Term /> <And />
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
I have got as follows: use constant ABC => ('one', 'two', 'three'); and I
The code that I have is as follows: <!DOCTYPE html> <html> <head> <script src=javascript/jquery.js

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.