`
fxxd1212
  • 浏览: 25641 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Android深入浅出系列课程---Lesson3 AAF110427_进程生命周期Process Lifecycle

阅读更多
大家好,上一讲我们介绍了Android中Log,这一讲我们来讲下进程生命周期Process Lifecycle。
一、课程目标:
        熟悉Android Process生命周期

    掌握Android进程的5个等级

二、重点难点:
        理解性的记忆Android的5个等级的的含义及转换关系

三、考核目标:
        请说出Android进程5个等级及区别?

    请说出Android进程5个等级优先级别

四、课后练习:
        写一个Demo,打出当前进程的等级
l 真人真事,一道面试题引发的故事:
1)思考题:Android的5个进程等级(Process Levels)?
l Android进程如何启动的?
l Android的5个进程等级(Process Levels)
1) Foreground Process
正处于Activity Resume() 状态

正处于与bound服务交互的状态

正处于服务在前台运行的状态 , (startForeground() 被调用)

Service生命周期函数正在被执行 ( onCreate() , onStart() , onDestroy())

BroadcastReceiver 正在执行onReceive()方法




杀死Foreground Process 需要用户响应-因为这个安全优先级是最高的

2) Visible Process
Activity 不在前端显示 , 但也没有完全隐藏,能够看得见,比如弹出一个对话框 。(Input Method)
一个bound到visible 或者 foreground 的activity的 Service


3) Service Process
正在运行的,不在上述两种状态的Service
4) Background Process
不可见状态的Activity进程,(onStop()被调用)
5) Empty Process
没有运行任何Components的进程,保留这个进程主要是为了缓存的需要
l 这里需要提到一点:如果又有Service又有Visible Activity怎么办?
From developer.android.com :
if a process hosts a service and a visible activity, the process is ranked as a visible process, not a service process.
当进程既有Service 并且 有Visible Activity的时候,进程会被认为是Visible 进程 。
得出结论:优先级高的为准。


本讲对Android中进程生命周期(Process Lifecycle)的介绍,下一讲将进入manifest,内容预告:AAF110429_介绍manifest文件的使用,敬请期待。

特别推荐新课程:Android开发高端课程
http://www.mobidever.com/forum.php?mod=viewthread&tid=2098
本课视频地址:http://www.tudou.com/programs/view/OSd-KEwesV4/ (土豆网)
课程下载地址:http://www.verycd.com/topics/2900036/ (VeryCD电驴)
作者博客:http://www.mobidever.com/forum.php (Sundy-Android开发联盟)
  • 大小: 27.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics