1

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.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
jfisk
  • 6,125
  • 20
  • 77
  • 113
  • 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 Answers3

6

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 .

Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • 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
2

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).

Sebastian Juarez
  • 3,317
  • 2
  • 21
  • 20
0

You can try setting the Splashscreen as a theme to your activity

DeRagan
  • 22,827
  • 6
  • 41
  • 50