JayVDiyk
JayVDiyk

Reputation: 4487

App Turns White Temporaryly when Intent is set with FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK

Intent intent = new Intent(LoginActivity.this, Profile.class);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

startActivity(intent);

overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);

I am using this flags to clear all activity stack after logging in. The problem is, the transition became really ugly since the screen turns to white momentarily. Any workaround to avoid this?

P.S.: Both activities has RED Color as their background. I am wondering where the white color cames from.

Upvotes: 5

Views: 2788

Answers (2)

blueware
blueware

Reputation: 5381

In your styles.xml file add this line:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:windowDisablePreview">true</item>
...
</style>

It will disable preview mode for the new loaded screen (aka white/black screen).

If you want to use a custom background before loading a new screen, consider adding the following line:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:windowBackground">@drawable/slash_screen</item>
...
</style>

Upvotes: 2

pRaNaY
pRaNaY

Reputation: 25310

Add below line in your app theme which disable windows preview before fragment or activity load.(white screen problem)

<item name="android:windowDisablePreview">true</item>

See here

Upvotes: 12

Related Questions