I have a splash screen/loading screen that has .setVisibility() to GONE right after the draw call of my large bitmap is completed. The problem is the splash screen takes a bit to popup which i believe is due to the main activity booting up and doing CPU intensive applications on first run. Is there a way to get my splash screen displayed ASAP? Would it be ok if i had it in a different thread maybe? The splash screen is just a bitmap with a progressBar right below it. My layout is xml based so i cant see myself using setContentView. Thanks.
- 125,853
- 70
- 238
- 294
- 5,947
- 20
- 73
- 111
-
IF you want a loading splash screen checkout: http://blog.blundell-apps.com/tut-splashscreen-with-progress-bar/ – Blundell Jun 21 '12 at 12:10
3 Answers
Would it be ok if i had it in a different thread maybe?
In android, when we build an application we may need to display a splash screen ( welcome screen ) for users to intimate some thing & do some other process in background ( like fetching data from DB, Parsing XML , etc.. ), so for that it is preferrable to implement it in a different thread.
I have referred the example on www.androidpeople.com site for the SPLASH SCREEN, you may also Have a look at this example of SPLASH SCREEN .
- 9,531
- 5
- 59
- 100
- 125,853
- 70
- 238
- 294
-
After reviewing the code, may I ask if this code `do other process in backgroud`? – SolessChong May 30 '13 at 08:01
-
I meant, your solution works fine for creating a splash screen. However, in my scenario, where I'm trying to load a webview in the `MainActivity`, it might not work, because the code seems to initialize the `MainActivity` only after the splash time expires. – SolessChong May 30 '13 at 09:31
You want a separate thread to execute tasks in background, while showing progress in the foreground and call the setVisibility(...) method you say after doing so.
I've come across this tutorial: http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1
I've found it excellent, it's easy to implement, only one class and after part 2 you learn how to really get rid of the AsyncTask definitevely (http://stackoverflow.com/questions/3077461/asynctask-threads-never-die-android).
- 3,276
- 2
- 20
- 18