zoukankan      html  css  js  c++  java
  • Android Activity生命周期

    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系统资源不足时被调用。

  • 相关阅读:
    poj1088 经典dp
    poj2301
    poj1050(nyoj104 zoj1074)dp问题
    hdu1003
    poj1001(高精度)
    图的深度优先遍历DFS
    jquery中attr和prop的区别
    Apache 配置域名入口路径
    关于启动定时器和取消定时器的问题
    Web攻防之XSS,CSRF,SQL注入
  • 原文地址:https://www.cnblogs.com/shihao/p/2695420.html
Copyright © 2011-2022 走看看