Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show splash image while loading activity

I have an activity that contains many UI views. In its onCreate method, I found single line of setContentView takes 8-12 seconds to be complete. So I want to show my logo image while it's loading. I tried many things but without any success. I suspect main reason might be that before finishing setContentView, nothing can be shown.

Any help would be appreciated.

UPDATE:

I think many people do not know that you cannot show any dialog before finishing setContentView. So using another splash activity does not help me at all.

UPDATE2

I forgot to update this question after I found cause of the problem. Please refer to following question: setContentView taking long time (10-15 seconds) to execute

like image 483
Tae-Sung Shin Avatar asked Nov 18 '11 07:11

Tae-Sung Shin


1 Answers

use AsyncTask

put splash in onPreExecute()

and do your work in doInBackground()

and close splash in onPostExecute()

like image 112
Dr.jacky Avatar answered Oct 13 '22 11:10

Dr.jacky