Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen flashes randomly when using overridePendingTransition on Jelly Bean

This problem only happens sometimes on Jelly Bean 4.1 and 4.2 (tested on Galaxy Nexus and Nexus 4). Here is how I use overridePendingTransition

When starts a new Activity:

Intent intent = new Intent(ActivityA.this, ActivityB.class);
startActivity(intent);
overridePendingTransition(R.anim.transition_right_to_left,
                    R.anim.transition_right_to_left_out);

When finish an Activity to back to previous one

finish();
overridePendingTransition(R.anim.transition_left_to_right, R.anim.transition_left_to_right_out);

transition_left_to_right

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXDelta="-100%p"
android:toXDelta="0" 
android:duration="@integer/transition_duration"/>

transition_left_to_right_out

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXDelta="0"
android:toXDelta="100%p" 
android:duration="@integer/transition_duration"/>

transition_right_to_left

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p"
android:toXDelta="0" 
android:duration="@integer/transition_duration"/>

transition_right_to_left_out

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0"
android:toXDelta="-100%p" 
android:duration="@integer/transition_duration"/>

And this is how screen flashes: http://youtu.be/TUKRz2yVF6Q (only happens from 01:00)

Please tell me if you know whats wrong with my code and why the device screen sometimes flashes? Thank you.

Edit: Tried to use ActivityOptions on Jelly Bean but it did not help

like image 430
Wayne Avatar asked Mar 01 '13 17:03

Wayne


1 Answers

I had the exact same issue. I was able to solve it by changing the interpolator to linear_interpolator instead of accelerate_decelerate_interpolator.

like image 129
Ido Sofi Avatar answered Sep 17 '22 12:09

Ido Sofi