Followed by either onRestart() if this activity is coming back to interact with the user, or onDestroy() if this activity is going away.
//当activity对用户不再可见时被调用,因为另一个activity已经重新开始并且覆盖了当前activity(在栈中)。当有新的activity被启动,或者一个存在的activity重新回到前台状态,又或者当前的activity将被销毁。如果activity要返回前台和用户进行交互则在此方法后调用onReatart方法,如果当前activity要消亡,则onDestroy方法将在此方法后被调用
onDestroy() 次状态下activity可以被终结
The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.
这是当你的activity被消亡时接收到的最后一个方法。调用此方法有两种情形:一是 activity将要完成,可通过调用finish方法实现。而是系统销毁activity的实例来释放空间。可以使用isFinish方法来区别两种情形。这个方法常用在onPause方法中,来判断activity是暂停还是将终止。后面的demo将会演示这个功能。
下图是官网的一个生命周期的演示
好了 看一下我写的一个演示的例子吧,
MainFest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://www.easck.com/apk/res/android"
package="uni.activity"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ActivityDemoActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity01"
android:label="@string/app_name">
</activity>
</application>
</manifest>











