xiaobailong24 / MVVMArms

Android MVVM Architecture Components based on MVPArms and Android Architecture Components.
Apache License 2.0
424 stars 64 forks source link

7.0的跑你那个apk 进去退出在进去有时会闪退 #3

Closed qq517103430 closed 7 years ago

xiaobailong24 commented 7 years ago

@qq517103430 感谢反馈,我查一下!

xiaobailong24 commented 7 years ago

@qq517103430 调试了,发现当按返回键退出 App 时,如果 瞬间 接着重新启动 App,Activity 的生命周期还没执行完毕,只进行到 onPause,对应的 Fragment 的生命周期也进行到 onPause。

这时会重新创建新的 Activity,但是 Fragment 的生命周期却没有执行。

 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@aee9983 ---> onActivityPaused
 I/ActivityLifecycle$Fragm: WeatherNowFragment{ef1563 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentPaused
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{be27560 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentPaused
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@8ec19b0 ---> onActivityCreated
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@8ec19b0 ---> onActivityStarted
 E/ActivityLifecycle$Fragm: HolderFragment{8b68d5b #0 android.arch.lifecycle.state.StateProviderHolderFragment}onFragmentAttached:
 I/WeatherNowFragment: setData: message.what--->101, message.obj--->北京,北京,中国
 D/AndroidRuntime: Shutting down VM
.............                                                                         

正常的生命周期是这样的:

 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@d428fb3 ---> onActivityPaused
 I/ActivityLifecycle$Fragm: WeatherNowFragment{a0edfd0 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentPaused
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{b66dbc9 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentPaused
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@d428fb3 ---> onActivityStopped
 I/ActivityLifecycle$Fragm: WeatherNowFragment{a0edfd0 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentStopped
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{b66dbc9 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentStopped
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@d428fb3 ---> onActivityDestroyed
 I/ActivityLifecycle$Fragm: WeatherNowFragment{a0edfd0 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentViewDestroyed
 I/ActivityLifecycle$Fragm: WeatherNowFragment{a0edfd0 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentDestroyed
 I/ActivityLifecycle$Fragm: WeatherNowFragment{a0edfd0 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentDetached
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{b66dbc9 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentViewDestroyed
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{b66dbc9 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentDestroyed
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{b66dbc9 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentDetached
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@b3e9b38 ---> onActivityCreated
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@b3e9b38 ---> onActivityStarted
 E/ActivityLifecycle$Fragm: HolderFragment{5956703 #0 android.arch.lifecycle.state.StateProviderHolderFragment}onFragmentAttached:
 W/ActivityLifecycle: me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity@b3e9b38 ---> onActivityResumed
 E/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0}onFragmentAttached:
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentAttached
 D/dagger.android.support: An injector for me.xiaobailong24.mvvmarms.weather.mvvm.view.fragment.WeatherNowFragment was found in me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentCreated
 E/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1}onFragmentAttached:
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentAttached
 D/dagger.android.support: An injector for me.xiaobailong24.mvvmarms.weather.mvvm.view.fragment.WeatherDailyFragment was found in me.xiaobailong24.mvvmarms.weather.mvvm.view.activity.WeatherActivity
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentCreated
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentViewCreated
 E/ActivityLifecycle$Fragm: DestructionReportFragment{56d66dc #0 android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag}onFragmentAttached:
 E/ActivityLifecycle$Fragm: HolderFragment{f1403e5 #1 android.arch.lifecycle.state.StateProviderHolderFragment}onFragmentAttached:
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentActivityCreated
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentStarted
 I/ActivityLifecycle$Fragm: WeatherNowFragment{af5b1f1 #1 id=0x7f0e00c4 android:switcher:2131624132:0} ---> onFragmentResumed
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentViewCreated
 E/ActivityLifecycle$Fragm: DestructionReportFragment{205f961 #0 android.arch.lifecycle.LifecycleDispatcher.report_fragment_tag}onFragmentAttached:
 E/ActivityLifecycle$Fragm: HolderFragment{8cec86 #1 android.arch.lifecycle.state.StateProviderHolderFragment}onFragmentAttached:
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentActivityCreated
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentStarted
 I/ActivityLifecycle$Fragm: WeatherDailyFragment{83a61d6 #2 id=0x7f0e00c4 android:switcher:2131624132:1} ---> onFragmentResumed
 I/zygote64: Waiting for a blocking GC ObjectsAllocated
 D/WeatherViewModel: loadLocationPaths: 北京,北京,中国
 I/WeatherNowFragment: setData: message.what--->101, message.obj--->北京,北京,中国

我会后续跟进,找出更深层的原因。

xiaobailong24 commented 7 years ago

@qq517103430 Have fixed it.

JessYanCoding commented 7 years ago

涉及到 MVPArms 吗?

xiaobailong24 commented 7 years ago

我试了MVArms,没再现过这种情况

JessYanCoding commented 7 years ago

ok