11

When I go one activity to another activity , between the transaction a Black screen is come for some seconds. I properly finish the activity before calling startActvity().

Am using android:theme="@android:style/Theme.Translucent" theme for my activity. Even though between the activity transaction a black screen is coming

Can any one please tell me how to resolve this

Thanks in advance :)

Binil Surendran
  • 2,524
  • 6
  • 35
  • 58
  • Are you using custom transition animations? i think that might solve your problem, use a fade out fade in animation to see if it solves your issue, have a look at http://stackoverflow.com/a/18475926/3065080 – Mushroomzier Dec 18 '15 at 10:12
  • I check with custom animation ,even thought a black screen comes for some seconds @ Mushroomzier – Binil Surendran Dec 18 '15 at 10:25
  • Try using a different theme or device. Just to find out what is causing the black screen. If we find the cause we can fix it☺ – Mushroomzier Dec 18 '15 at 10:31

5 Answers5

2

There is no need to finish activity before calling startActivity().

Make sure that you have set content view in the onCreate of called Activity and that you are not blocking UI thread (check onCreate, onStart and onResume if you have override them).

Milos Fec
  • 828
  • 6
  • 11
2

You don't need to manage finshing your activity, this will be managed automatically when the activity is no longer in view. Just use:

startActivity(new Intent(this, MyNextActivity.class));

And use this code in whatever method you are using to navigate the activity changes.

If you make sure your window is the background of your activities you can set the window background to a color other than black:

<item name="android:windowBackground">@drawable/window_background</item>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="@color/window_background"/>
</shape>

windowBackground in Android 6 (Marshmallow)

The other option is to manage transitions, so there is no gap between the end of the first transition and the beginning of the second. However, you have not mentioned transitions.

How to remove the delay when opening an Activity with a DrawerLayout?

Community
  • 1
  • 1
2

for disable this default animation create one style:

<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">@null</item>
</style>

and set it as theme for your activity in the manifest:

<activity android:name=".ui.ArticlesActivity" android:theme="@style/noAnimTheme">
</activity>
santoXme
  • 802
  • 5
  • 20
1

Assumption :-

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.xyz);

    // comment code here
    }

If you go from activity A to B then try to comment code in OnCreate , OnResume in Activity B Like this and check what happen still black screen is coming or not.If coming then try to change theme.

Hiren
  • 285
  • 1
  • 2
  • 13
0

If you have a finish() or FLAG_ACTIVITY_CLEAR_TASK - a blank screen may show up on pre ICS devices

To avoid this black screen you have to add one line in intent

overridePendingTransition (0, 0);

Example(kotlin):

val intent = Intent(applicationContext, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
overridePendingTransition (0, 0)

Example(Java):

Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
overridePendingTransition (0, 0);
F_Z
  • 581
  • 3
  • 16