android 生命周期 详解
来源:互联网 发布:数据分析与统计 编辑:程序博客网 时间:2024/05/22 14:20
程序启动
按 返回键
按Home键
当再次打开应用程序时
从第一个页面跳转到第二个页面
从第二个页面返回第一个页面
整体流程图
附上测试程序的源代码
package com.xz.androidlifecycle;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity { private static final String TAG = "LifeCycle"; private Button btn;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.e(TAG, "start onCreate");btn = (Button) findViewById(R.id.btn);btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {Intent it = new Intent();it.setClass(MainActivity.this, SecondActivity.class);startActivity(it);}});}@Overrideprotected void onStart() {super.onStart();Log.e(TAG, "start ------------onStart-----------");}@Overrideprotected void onRestart() {// TODO Auto-generated method stubsuper.onRestart();Log.e(TAG, "start -----------onRestart-----------");}@Overrideprotected void onResume() {super.onResume();Log.e(TAG, "start -----------onResume-----------");}@Overrideprotected void onStop() {super.onStop();Log.e(TAG, "start -----------onStop-----------");}@Overrideprotected void onPause() {super.onPause();Log.e(TAG, "start -----------onPause-----------");}@Overrideprotected void onDestroy() {super.onDestroy();Log.e(TAG, "start -----------onDestroy-----------");}}
package com.xz.androidlifecycle;import android.app.Activity;import android.os.Bundle;import android.util.Log;public class SecondActivity extends Activity{ private static final String TAG = "SecondLifeCycle"; @Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.e(TAG, "start onCreate");}@Overrideprotected void onStart() {super.onStart();Log.e(TAG, "start ------------onStart2-----------");}@Overrideprotected void onRestart() {// TODO Auto-generated method stubsuper.onRestart();Log.e(TAG, "start -----------onRestart2-----------");}@Overrideprotected void onResume() {super.onResume();Log.e(TAG, "start -----------onResume2-----------");}@Overrideprotected void onStop() {super.onStop();Log.e(TAG, "start -----------onStop2-----------");}@Overrideprotected void onPause() {super.onPause();Log.e(TAG, "start -----------onPause2-----------");}@Overrideprotected void onDestroy() {super.onDestroy();Log.e(TAG, "start -----------onDestroy2-----------");}}
0 0
- Android Activity 生命周期详解
- Android Activity生命周期详解
- android activity 生命周期详解
- Android Activity生命周期详解
- Android MediaPlayer生命周期详解
- Android Activity生命周期详解
- Android生命周期详解
- Android Fragment 生命周期详解
- Android Activity生命周期详解
- 详解Android Activity 生命周期
- android生命周期详解
- Android Activity生命周期详解
- android生命周期详解
- Android中生命周期详解
- android activity 生命周期详解
- android 生命周期 详解
- 【Android】Activity 生命周期详解
- android Activity 生命周期详解
- ios学习资料
- 将Map的内容按value排序
- Linux下多版本jdk的切换 alternatives
- Tomcat配置数据库连接池
- 最新首发Eclipse+CDT+android-ndk写纯c++安卓应用(附openGL Es)
- android 生命周期 详解
- Android WebRTC 音视频开发总结(一)
- 2015年工作中遇到的问题:51-60
- 英文版SQL Server 2008使用时,字段中存在中文的要注意编码问题
- 开源框架Universal-Image-Loader(一) 基本介绍及使用
- Android Volley完全解析(二),使用Volley加载网络图片
- DEV 的Gridiew Ctrl + C 和 Ctrl + V
- UNIX网络编程——原始套接字的魔力【上】
- 入门级freemarker的使用