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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:06:55+00:00 2026-06-10T05:06:55+00:00

Hi I wanted to add a delay on my splash screen using a Async

  • 0

Hi I wanted to add a delay on my splash screen using a Async Task but I can’t figure out how should I do it. Here’s my DoInBackground code so far:

@Override
        protected Integer doInBackground(String... params) {

            Thread SplashThread = new Thread() {
                    @Override
                    public void run() {
                        try {
                            int waited = 0;
                            while(running && (waited < delayTime)) {
                                sleep(100);
                                if(running) {
                                    waited += 100;
                                }
                            }
                        } catch(InterruptedException e) {
                            // do nothing
                        } finally {
                            finish();
                            stop();
                        }
                    }
                };
                SplashThread.start();

            return null;
        }

I think the part of the return null is the main cause of problem since it’s ending up my Async Task even my SplashThread is still running in background leaving a leak on thins part onwards which lead to error. I also tried to use counDownTimer as a subtitute but this leads in the same problem. Any ways to do this properly?

  • 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-10T05:06:56+00:00Added an answer on June 10, 2026 at 5:06 am

    You don’t need the additional thread that you start in the doInBackground method of your AsyncTask. The AsyncTask itself runs the doInBackground method in another thread, also,
    because of this the while loop it’s most likely unnecessary. Do the work you want to do in the doInBackground method and then simply return. If you want/need some additional delay(although you should avoid this at all costs) you can use the Thread.sleep method to pause the thread before returning.

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

Sidebar

Related Questions

I wanted to add a contextmenu to a tabitem. But it should only be
Lets say i wanted to add another variable to the database can anybody tell
Found this at MDC but how if I'd wanted to add a private variable
I wanted to add an Xcode project to an existing repository using the following:
I wanted to add a certain set of files in a directory using svn
If i wanted to add an attribute to the root element record, can i
I wanted to add more methods to the Calendar from java.util.Calendar, but I'm having
I wanted to add icons to my tabview, but it dont work and look
I wanted to add a normal map information for my shader. I was using
My webapp is ready but I just wanted to add a little dropdown menu

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.