我正在尝试将TransitionListener
添加到默认活动转换中,如下所示:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getEnterTransition().addListener(new TransitionAdapter());
}
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private class TransitionAdapter implements Transition.TransitionListener {
@Override
public void onTransitionStart(Transition transition) {
Log.i("transition", "onTransitionStart");
}
@Override
public void onTransitionEnd(Transition transition) {
Log.i("transition", "onTransitionEnd");
}
@Override
public void onTransitionCancel(Transition transition) {
Log.i("transition", "onTransitionCancel");
}
@Override
public void onTransitionPause(Transition transition) {
Log.i("transition", "onTransitionPause");
}
@Override
public void onTransitionResume(Transition transition) {
Log.i("transition", "onTransitionResume");
}
}
这是我如何开始活动: Intent intent = new Intent(activity,LoginActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Bundle options = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
activity.startActivityForResult(intent, RequestCodes.SIGN_IN, options);
} else {
activity.startActivityForResult(intent, RequestCodes.SIGN_IN);
}
问题是真实设备上没有调用回调。它适用于genymotion。是否需要一些额外的设置?
免责声明:我在lolipop运行设备上测试它
答案 0 :(得分:0)
发现它在5.0上不起作用但在5.1上修复了所以它显然是一个安卓漏洞。虽然我不知道解决方法。我已将转换限制为最低API 22。