Closed dary123 closed 4 years ago
先描述一下你的需求场景
我的需求场景是在ImagePreviewActivity当前页面跳转到一个新页面,需要用到转场动画,所以必须要有当前页面的上下文
你的跳转是如何触发的?
Intent intent = new Intent(AppManager.AppManager.currentActivity(), ShareMsgInfoFromFindActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); AppManager.AppManager.currentActivity().startActivity(intent); AppManager.AppManager.currentActivity().overridePendingTransition(R.anim.slide_in_up, R.anim.anim_hold);
你使用了:AppManager.AppManager.currentActivity() 应该没问题吧,你可以看一下AppManager.AppManager.currentActivity()获取的是不是ImagePreviewActivity。
如果获取的不是查看大图的activity,你可能需要更改一下Appmanager的实现。推荐使用ActivityLifecycleCallbacks进行监听当前activity。
AppManager.AppManager.currentActivity()获取到当前activity的前提是我必须要在AppManager.AppManager这个枚举里存储每一个打开activity,因为在ImagePreviewActivity没有add到存储的Activity栈里,所以currentActivity获取到的是上一个activity
ActivityLifecycleCallback会影响性能吗
建议你去了解一下ActivityLifecycleCallback。
建议不要使用addActivity的方式管理activity栈。
因为我之前用过ActivityLifecycleCallback,放在application里面,结果会导致App卡顿
如何获取ImagePreviewActivity当前的上下文