onDestroy()没有被调用,而活动正在被用户杀死? [英] onDestroy() not getting called while the activity is getting killed by the user?

查看:482
本文介绍了onDestroy()没有被调用,而活动正在被用户杀死?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个标签的活动。单击两个选项卡将更改选项卡下面的片段。虽然那个活动是在前面我给出一个通知,之后,我最小化的应用程序,并杀死那个活动(不是强制停止)。

I have an activity with two tabs. Clicking on two tabs will change the the fragments below the tabs. While that activity is in front I give out a notification, After that I minimize the app and kill that activity(not force stopping).

我的问题是,在活动被用户杀死时,在 onDestroy 现在,如果我点击通知,应用程序将强制关闭,因为等待意图的活动已丢失。为什么不能在onDestroy中调用回调? $

My problem is that am not getting call back in onDestroy while the activity is been killed by the user. Now if I click the notification the app will force close and thats because the activity for pending intent is been missing. Why am not getting the call back in onDestroy?

推荐答案

不能确保在片段的 onDestroy 。当我们杀死应用程序活动的 onDestroy()将获得回调,活动将被杀死,片段可能无法回调。

It is not sure to get callback in fragment's onDestroy(). When we kill the app Activity's onDestroy() will get the callback and the activity will be killed and fragment may not get callback.

这篇关于onDestroy()没有被调用,而活动正在被用户杀死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆