gpt4 book ai didi

android - 监听默认 Activity 转换

转载 作者:太空狗 更新时间:2023-10-29 14:53:43 28 4
gpt4 key购买 nike

我正在尝试将 TransitionListener 添加到默认 Activity 转换中,如下所示:

@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");
}
}

这是我开始 Activity 的方式: 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 运行设备上测试它

最佳答案

发现它在 5.0 上不起作用,但在 5.1 上得到修复,所以这显然是一个 android 错误。不过,我不知道解决方法。我已将转换限制为最低 API 22。

关于android - 监听默认 Activity 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33191019/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com