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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:50:57+00:00 2026-06-13T07:50:57+00:00

Is it possible to load a new activity in the background before switching the

  • 0

Is it possible to load a new activity in the background before switching the view to that activity?

For example, I would like to have a slash screen activity that gets called and displays a splash screen. While this splash screen is displayed, the next activity is loaded, and when it is done loading (when it’s onCreate() is finished) then the splash screen activity ends, and the new activity is displayed.

I know another option would be to display the splash screen in the new activity, and use async task to load all the data before removing the splash image… but I am stuck on that approach as well. The activity first has to load a fair amount of data, and then it has to dynamically add GUI elements based on that data. Once the GUI is fully loaded, I then want to remove the splash screen. The problem is that I cannot touch the UI thread from doInBackground(). How do I create my activity behind a splash screen, if I cannot update the UI from doInBackground? I know that onProgressUpdate() can access the UI thread, but I can’t figure out how to implement it.

Any ideas? Thank you!

  • 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-13T07:50:58+00:00Added an answer on June 13, 2026 at 7:50 am

    Since you don’t have an example of your code, I am not sure what kind of data you are loading and how you are dynamically configuring the UI based on the data, but I’ll try to answer as much as I can. As a result, the answer may sound a little generic.

    First, define 2 layout xml files – one for the splash screen and one for your “main” activity.
    So you’ll end up with /res/layout/splash_screen.xml and /res/layout/main.xml

    In your onCreate(), load the splash_screen layout:

    setContentView(R.layout.splash_screen);
    

    In your async task, you will load up whatever data you need to do, and you will save all that data in some sort of data structure. I’m gonna use a LinkedList of String for example’s sake.

    private class MyTask extends AsyncTask<Uri, Integer, List<String>> {
    
        @Override
        protected List<String> doInBackground(Uri... params) {
            List<String> myList = new LinkedList<String>();
            // load up the list with data you are trying to get
            myList.add("foo");
            myList.add("bar");
            // whatever you return here will be passed in as a parameter to the onPostExecute()
            return myList;
        }
    
        @Override
        protected void onPostExecute(List<String> result) {
            setContentView(R.layout.main2);
            // set layout elements with data that from the result
            TextView myTextView = (TextView) findViewById(R.id.some_label);
            myTextView.setText(result.get(0));
            // or just call some function you defined in your activity instead
        }
    }
    

    So basically, have 2 different layout file and use the splash_screen layout, and use the async task the load the data and save it in some data structure you define, and use that data structure to load your UI elements in onPostExecute() after using setContentView() to change back to your main layout.

    One special note:
    With the above code, it will show the splash screen again and reload all the data again if you rotate the screen. If you want to avoid that, you can use the onSaveInstanceState() and save whatever data you want in the outBundle and read that data back in onCreate’s savedInstanceState bundle and load the UI elements back up. This will require a separate thread (or you can just search about it) if you wanted to know more about handling rotation.

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

Sidebar

Related Questions

Possible Duplicate: jquery/ajax load new content when available i have a table named news
I have an application where it is possible to load new content through usercontrols.
is it possible in Db4o to load new objects into persistent IObjectContainer? I have
Is it possible to load new data between td tags and change the background
Is it possible to load new lines from a text file to variables in
Is it possible to load a User Control that was registered in the web.config
I would like to know if it's possible to change the contents of the
I have a div which contains data. I would like when a user clicks
I am new to WebParts and have a newbie question... is it possible to
Is it possible to load a view from a database rather than from a

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.