Is it possible to display the progressbar dialog before calling setContentView () in Android activity?

In my Android application, it takes more than 10 seconds to load (it contains several text elements with long text values), now I want to show the progress bar dialog box while Activity is loading? Can I use "AsyncTask"? if possible, how can I pause the user interface thread until AsyncTask is complete. When I try to show a dialog before calling setContentView (), I get an error, for example android.view.WindowManager $ BadTokenException: cannot add a window - the null token is not for the application

+4
source share
2 answers

You can use AsyncTask and Viewswitcher to switch between two layouts (each layout is a view). First set the contentView and in onPostExecute (after loading) switch your layouts.
Edit:
See this page for more information.

+1
source

you can add a timer thread where you can specify the time during which you want to help load the second activity.

0
source

All Articles