Here is something work with 5.0 sdk got after 10/17/14.
But not sure what is the expected behavior if enable window content transitions and called setEnterTransition
/setExitTransition
in both mainActivity
and secondActivity
. If they are different (e.g one choose Explode and other choose Slide), which one would be applied?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
To enable window content transitions in your code instead, call the Window.requestFeature() method:
*/
getWindow().requestFeature(android.view.Window.FEATURE_CONTENT_TRANSITIONS);
Transition ts = new Explode(); //Slide(); //Explode();
ts.setStartDelay(2000);
ts.setDuration(5000);
/*
If you have set an enter transition for the second activity,
the transition is also activated when the activity starts.
*/
getWindow().setEnterTransition(ts);
getWindow().setExitTransition(ts);
setContentView(R.layout.activity_main_view);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, mainViewFragment.newInstance())
.commit();
}
}
public void launchSecondActivity() {
/*
If you enable transitions and set an exit transition for an activity,
the transition is activated when you launch another activity as follows:
*/
Intent listIntent = new Intent(this, secondActivity.class);
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
}
}
//===
public class secondActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
///
getWindow().requestFeature(android.view.Window.FEATURE_CONTENT_TRANSITIONS);
Transition ts = new Slide(); //Slide(); //Explode();
ts.setDuration(3000);
getWindow().setEnterTransition(ts);
getWindow().setExitTransition(ts);
///
setContentView(R.layout.activity_scene_transition);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}