1

离开活动时如何显示活动,方法“OnDestroy”中的执行

protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        Bundle savedInstanceState = null;
        this.onCreate(savedInstanceState);


    //launch a code to display a activity   



    }
4

3 回答 3

2

onCreate(savedInstanceState)是您的方法中的super调用。像你开始任何事情一样做onCreate()ActivityActivity

protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
startActivity(intent);
}

你现在在哪里CurrentAcivity,你想从哪里开始。ActviityNextActivityActviity

意图

活动

通读上面的文档并特别注意活动生命周期。你不必这样做onDestroy(),如果这就是你在那里所做的一切,那么你根本不需要覆盖onDestroy()。您可以将其放在代码中的任何位置并调用finish()onDestroy()系统会自动为您调用

于 2013-04-21T13:55:05.367 回答
1

您可以在此处查看此方法的文档。

http://developer.android.com/training/basics/firstapp/starting-activity.html

于 2013-04-21T14:01:21.957 回答
0

onCreate 在创建活动时调用。

当您需要创建活动时,您不会调用它。

为了开始一个新的活动,调用 startActivity()。

于 2013-04-21T14:22:58.003 回答