Title: How to display progress screen while restarting app?
Tags: android
Question: I do app restart with the following intent:
Intent restartIntent = new Intent(context, MainActivity.class);
restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
restartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(restartIntent);
But there is "white" screen while restarting.
I want to display custom screen instead, while restarting app.
Do you know how to achieve this?
Comment: @Wojtek Provided link is about progress bar component. I need to display custom screen while restarting app.

Comment: @MatteoUgolotti thanks, it doesn't solve my issue

Comment: @WojtekT my question is not about displaying progress bar while loading data but about displaying separate screen while restarting app

Comment: Maybe this could be helpful https://stackoverflow.com/questions/8133118/run-progress-bar-while-switching-activity and https://stackoverflow.com/questions/15153345/how-to-get-spinning-progress-bar-at-starting-of-application

Comment: You probably can't display animating progress but you can create splashscreen. It will style white window which you have while restarting app. Check this https://android.jlelse.eu/the-complete-android-splash-screen-guide-c7db82bce565 and this https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd

Comment: Have you looked at this? https://developer.android.com/reference/android/widget/ProgressBar

Comment: Possible duplicate of [How to get Spinning Progress Bar at starting of Application](https://stackoverflow.com/questions/15153345/how-to-get-spinning-progress-bar-at-starting-of-application)

Here is the accepted answer: You probably can't display animating progress but you can create splashscreen. It will style white window which you have while restarting app. Check this and this

Here is another answer: To get rid of the white screen which is because of android's cold start, and appears when the app loads to memory, you can add the following style item to your AppTheme.
<item name="android:windowDisablePreview"&gt;true</item&gt;
Now, In your MainActivity startup, you can display progressBar or anything like placeholder View while your data is being loaded in background and once loaded, hide progress/placeholders etc. You can also create an intermediate Activity/View something like SplashScreen to be displayed on restart Intent instead of using progressBar in your MainActivity.
Comment for this answer: thanks, your answer helped me to get rid of white screen before launching screen for some time.

Here is another answer: I had the same issue and solved it by clearing the stack manually with finishAffinity():
Intent restartIntent = new Intent(context, MainActivity.class);
startActivity(restartIntent);
finishAffinity();
This way, the transition to your MainActivity does not show the blank screen for a short lapse of time.
If you want a loading screen, you can go to an Activity with the ProgressBar and use this code in that Activity's onCreate.
I know it is not the best solution but it is the only way I could make it work.

Here is another answer: To set a background drawable while an activity is starting you should use something like this:
<style name="AppTheme.NoActionBar.SplashTheme"&gt;
<item name="android:windowBackground"&gt;@drawable/splash</item&gt;
</style&gt;
as the activity's theme. It will show given drawable instead of the white screen.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:08/24/18', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<android>', 'Title': 'How to display progress screen while restarting app?', 'ViewCount': 304, 'id': 52004233, 'user_AboutMe': None, 'user_AccountId': 5816059.0, 'user_DisplayName': 'majov', 'user_Reputation': 545.0, 'user_Views': 59.0, 'user_id': 4585659.0}}