onCreate(创建) 、onStart(激活) 、onResume(恢复) 、onPause(暂停) 、onStop(停止) 、onDestroy(销毁) 、onRestart(重启)

Activity starts -->onCreate()-->onStart()-->onResume()-->activity is running--another activity comes in front of this activity-->onPause()--the activity is no longer visivble-->onStop()-->onDestroy()-->activity is shut down

notes:

When the “onPause()“excute,other applications need memory ,then Process is killed(User navigates back to activity),last excute onCreate()。

When the “onPause()“excute,the activity comes to the foreground,so it will excute onRestart(),last excute onstart()。

各个函数使用的时间:

1、onCreate()
Acitivity首次创建时被调用。用于设置Acitivity的布局文件,绑定按钮监听器等一些普通静态操作。

2、onStart()
Acitivity对用户可见时被调用。

3、onResume()
Acitivity获得用户焦点,即用户可操作该Acitivity时被调用。

4、onPause()
应用程序启动了其它Acitivity时被调用。一般用于保存当前Acitivity中的数据。

5、onStop()
Acitivity不可见时被调用。

6、onRestart()
已停止的Acitivity重新启动时被调用。

7、onDestroy()
调用Acitivity的finish()方法或Android系统资源不足时被调用。

更多相关文章

  1. android 调用相册里的图片并返回
  2. Android(安卓)调用系统播放器
  3. Android(安卓)LK Bootlaoder启动概览
  4. react-native调用Android原生模块
  5. android 6.0权限问题处理的核心代码--shouldShowRequestPermissi
  6. android经常调用的组件
  7. Android(安卓)Surface 介绍
  8. Android调用自定义Dialog中的控件
  9. android 调用系统日历

随机推荐

  1. android 一些总结 1.2-1.10
  2. Android:onTouch()和onTouchEvent()的区
  3. Android软键盘弹出,界面整体上移的问题
  4. animation的xml定义中的android:interpol
  5. A-GPS定位与GPS定位的Android简单实现
  6. 健身小管家--android app源码
  7. Android(安卓)软键盘在有scollview,纵向vi
  8. Android——天气预报(酷欧天气)(第三篇)
  9. Android(安卓)KTX简介
  10. Android中Handler Runnable与Thread的区