chimbu chimbu - 1 year ago 57
Android Question

Android : When I open the app it shows a white screen for a few seconds

When I open the app it shows a white screen for a few seconds for starting the service and all other things.

Can I avoid it by using a custom boot/loading screen loader or any other method is possible? and where I can put that code?

Help me, Thanks advance..


Its happening because of you may be doing some the time consuming task in application UI thread. You have to do that task using Async or separate thread.

Whenever you are trying to do some time consuming tasks in your application's main UI thread it always blocks the UI.

You can also use the Handler. Android provides additional constructs to handle concurrently in comparison with standard Java. You can use the android.os.Handler class or the AsyncTasks classes.

The AsyncTask class encapsulates the creation of a background process and the synchronization with the main thread. It also supports reporting progress of the running tasks.

   class task extends AsyncTask<String, Integer, String> {
    protected String doInBackground(String... params) {
             //your logic 
                 return null;

For more details Check