When switching between actions, a white screen is displayed.

When I move from one action to another, a white screen is displayed for 2 seconds. I am using this code:

Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); 

How can I solve this problem?

+6
source share
9 answers

Create a theme as follows:

 <style name="YourTheme" parent="YourParentTheme"> <item name="android:windowDisablePreview">true</item> </style> 

Apply this theme to your second action

More details in this link: http://www.tothenew.com/blog/disabling-the-preview-or-start-window-in-android/

+8
source

If your activity contains more complex layouts, do not use finish() after setting the flag. Use FLAG_ACTIVITY_CLEAR_TOP and _TASK instead, and it will solve your problem. This works great for me.

Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.lฬฅFLAG_ACTIVITY_CLEAR_TOP ); startActivity(intent);

or just use below

Intent intent = new Intent(this, SecondActivity.class); startActivity(intent);

+2
source

If your activity contains more complex layouts / contains a large focal image, it renders, so only this white page is displayed. If you want to remove this time delay, use low png images and clear layout schemes.

+1
source

Using FLAG_ACTIVITY_NEW_TASK , you get a white screen, remove it as you use it. He will work.

 Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); 
+1
source

When switching from ActivityOne to ActivityTwo until the ActivityTwo onCreate process is completed, the background is displayed, which is a white / black screen. Good practice is not a tough operation in onCreate. To fix the problem, set a transparent background for ActivityTwo, as shown below.

 <style name="YourTheme" parent="YourParentTheme"> <item name="android:windowBackground">@android:color/transparent</item> </style> 

In the manifest above the theme

 <activity android:name=".ActivityTwo" android:theme="@style/YourTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 
+1
source

Try adding intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); before calling startActivity(intent);

 Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 
0
source

Use the flag to go to the next step.

 Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 
0
source

Try adding intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

0
source

use finish , if you want to clear activity means when pressed, then there is no activity stack.

So you want to clean, use finish , otherwise do not use it.

0
source

All Articles