0

I have seen nice diagrams showing the lifecycle of an activity, but I can not find a diagram showing the lifecycle of an application - is there one?

In an activity onCreate is kind-of paired with onStop, I say paired in as much as you know for sure that if onStop() is called then you know for sure that the activity won't run again without calling onCreate(), you can see this at a glance from the diagram.

The particular thing I'm looking for is what method is paired with onCreate in the lifecycle of an application? is it onTerminate?

EDIT: I have something like the following:

public class myapp extends Application
{
    @Override
    public void onCreate()
    {
             special_function_startup();
    }
}

I want to have a special_function_shutdown() somewhere and I don't want special_function_startup() to be called if it is already started up. So the perfect place to put the special_function_shutdown() is in the method that "corresponds to" onCreate(), like onStop() does in an activity.

4

2 回答 2

2

有四种不同类型的应用程序组件。每种类型都有不同的用途,并有不同的生命周期来定义组件的创建和销毁方式。

以下是四种类型的应用程序组件: 活动 服务 广播接收器 内容提供者

因此,应用程序的生命周期取决于其组件的生命周期。

于 2013-03-01T16:47:00.027 回答
1

我找不到显示应用程序生命周期的图表 - 有吗?

并不真地。

我正在寻找的特别是在应用程序的生命周期中与 onCreate 配对的方法是什么?

如果您所说的“应用程序”是指Application,那么没有任何东西与onCreate(). AnApplication永远不会被显式销毁;它在整个过程生命周期中都存在。

是onTerminate吗?

onTerminate()永远不会被调用。

于 2013-03-01T16:52:14.710 回答