🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
http://m.blog.csdn.net/blog/yhc13429826359/19977429 ## 1生命周期图 ![](https://box.kancloud.cn/2016-03-16_56e8da7d55bda.png) ## 2主要类图调用 ![](https://box.kancloud.cn/2016-03-16_56e8da7d6f980.jpg) 上面类图关系中包含两个进程,一个是应用程序进程,另一个是AMS进程,所以会涉及到进程间通信,android进程间通信用的是Binder通信。 ### 2.1客户进程 ØActivityThread 可以看到该类有一个main方法,其实它是android一个应用程序的入口,每启动一个应用进程,都会创建ActivityThread与之对应的实例,是应用程序的UI线程,Android进程启动时会建立消息循环。负责管理应用程序的生命周期,执行系统广播及其ActivityManagerService请求执行的操作。属于客户端对象。 ØApplicationThread&ApplicatinThreadNative ApplicationThread用来实现ActivityManagerService与ActivityThread之间的交互。在ActivityManagerService需要管理相关Application中的Activity的生命周期时,通过ApplicationThread与ActivityThread通讯,ApplicationThreadNative是ApplicationThread在客户端的实现。 ØApplicationThreadProxy ApplicationThreadProxy是ApplicationThread在服务器端的代理。负责和服务器端的ApplicatingThreadNative通讯。 AMS就是通过该代理与ActivityThread进行通信的。 ØActivity& Intrumentation Activity是应用程序真正做事情的类,每一个应用程序只有一个Instrumentation对象,每个Activity内都有一个对该对象的引用。Instrumentation可以理解为应用进程的管家,ActivityThread要创建或暂停某个Activity时,都需要通过Instrumentation。通俗的理解,Instrumentation与ActivityThread的区别,前者像是一个“家庭”里的“管家”,后者是负责创建这个“家庭”,并负责对外打交道,比如接收AMS的通知等。 ### 2.2 AMS进程 这里说的AMS进程,实际指的是System_server进程,System_server进程起来的时候启动AMS服务,AMS实际是ActivityManagerService的缩写。 ØActivityManagerService 管理Activity的生命周期 ØActivityManagerNative ActivityManagerService在服务器端的实现,客户端的请求调用ActivityManagerProxy后,通过IBinder,最终会在ActivityManagerNative中实现。ActivityManagerNative再通过调用ActivityManagerService的相关功能,以完成客户端请求。 ØActivityManagerProxy ActivityManagerService的在客户端的代理。负责和服务器端的ActivityManagerNative通讯。 ØActivityStack Activity在AMS的栈管理,用来记录已经启动的Activity的先后关系,状态信息等。通过ActivityStack决定是否需要启动新的进程。 ØActivityRecord ActivityStack的管理对象,每个Activity在AMS对应一个ActivityRecord来记录Activity的状态以及其他的管理信息。 ØTaskRecord AMS抽象出来的一个“任务”的概念,是记录ActivityRecord的栈,一个“Task”包含若干个ActivityRecord。AMS用TaskRecord确保Activity启动和退出的顺序。 ØProcessRecord 一个Apk文件运行时会对应一个进程,ProcessRecord正是记录一个进程中的相关信息。 ## 3startActivity流程 在Android系统中,应用程序是由Activity组成的,因此,应用程序的启动过程实际上就是应用程序中的默认Activity的启动过程。启动Android应用程序中的Activity的两种情景,第一,在android设备屏幕中点击应用程序图标的情景就会引发Android应用程序中的默认Activity的启动,从而把应用程序启动起来,这种启动方式的特点是会启动一个新的进程来加载相应的Activity。第二,应用程序内部启动非默认Activity的过程的源代码,这种非默认Activity一般是在原来的进程和任务中启动的。在Android的Activity管理机制中,当退出Activity的时候,在某些情况下并没有立即把该Activity杀死,而是将其暂时保存起来,当第二次调用startActivity启动该Activity的时候,就不需要再创建该Activity的实例,直接恢复Activity即可。 ### 3.1调用流程图 ![](https://box.kancloud.cn/2016-03-16_56e8da7d8a671.jpg) 对用户来讲,启动一个Activity有以下几种方式: Ø在应用程序中调用startActivity()启动指定的Activity Ø在Home程序中点击一个应用图标,启动新的Activity Ø按“Back”键,结束当前Activity,自动启动上一个Activity Ø长按“Home”键,显示当前列表中,从中选则一个启动 对于AMS内部讲,启动一个Activity有三种方式,如上图中的①②③分支: ①目标Activity的对象已经存在,那么直接resume该Activity ②目标Activity所在的进程不存在,那么需要创建进程,并在新的进程中启动该Activity ③目标Activity所在进程已经存在,那么直接在已存在进程中启动该Activity ### 3.2在新的进程中启动 以在Home程序中点击一个应用图标,启动MainActivity为例子,介绍如下。 时序图如下图: [![框架层理解Activity生命周期](https://box.kancloud.cn/2015-10-30_5632e1cc04fc3.gif "框架层理解Activity生命周期")](http://photo.blog.sina.com.cn/showpic.html#blogid=89f592f501014ayc&url=http://s4.sinaimg.cn/orignal/89f592f5gcdfcee0f5513) ![](https://box.kancloud.cn/2016-03-16_56e8da7da4b63.jpg) 以上时序图包含35步骤调用,下面逐一讲解: ### 3.2.1(1~4),Launcher中发送startActivity请求 在Android系统中,应用程序是由Launcher启动起来的,其实,Launcher本身也是一个应用程序,其它的应用程序安装后,就会Launcher的界面上出现一个相应的图标,点击这个图标时,Launcher就会对应的应用程序启动起来。 Launcher继承与Activity,Activity类的有个成员变量mInstrumentation是,它的类型是Intrumentation,它用来监控应用程序和系统的交互。 Instrumentation.execStartActivity: <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="549" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">publicActivityResult execStartActivity(</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">Context who, IBinder contextThread, IBinder token, Activitytarget,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">Intent intent, int requestCode, Bundle options) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">IApplicationThread whoThread = (IApplicationThread)contextThread;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">try {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">intent.setAllowFds(false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">intent.migrateExtraStreamToClip<wbr style="padding:0px; margin:0px">Data();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">int result = ActivityManagerNative.getDefault()</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">.startActivity(whoThread, intent,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">intent.resolveTypeIfNeeded(who.getContentResolver()),</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">token, target != null ? target.mEmbeddedID : null,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">requestCode, 0, null, null, options);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">checkStartActivityResult<wbr style="padding:0px; margin:0px">(result, intent);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} catch (RemoteException e) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> 这里的ActivityManagerNative.getDefault返回ActivityManagerService的远程接口,即ActivityManagerProxy接口。 ### 3.2.2(5-8) AMS接收客户端startActivity请求 客户端通过Binder调用,最终调用到ActivityStack.startActivityLocked: <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">final intstartActivityLocked(IApplicationThread caller,</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">Intent intent, String resolvedType, ActivityInfo aInfo, IBinderresultTo,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">String resultWho, int requestCode,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">int callingPid, int callingUid, int startFlags, Bundleoptions,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">boolean componentSpecified, ActivityRecord[] outActivity){</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ProcessRecord callerApp = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (caller != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">callerApp = mService.getRecordForAppLocked(caller);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (callerApp != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">callingPid = callerApp.pid;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">callingUid = callerApp.info.uid;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord sourceRecord = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord resultRecord = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">int launchFlags = intent.getFlags();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if((launchFlags&amp;Intent.FLAG_ACTIVITY_FORWARD_RESULT)!= 0</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">&amp;&amp; sourceRecord != null){</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Transfer the result target from the source activity to thenew</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// one being started, including any failures.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">…….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord r = new ActivityRecord(mService, this, callerApp,callingUid,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">intent, resolvedType, aInfo, mService.mConfiguration,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">resultRecord, resultWho, requestCode,componentSpecified);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (outActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">outActivity[0] = r;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">err = startActivityUncheckedLo<wbr style="padding:0px; margin:0px">cked(r, sourceRecord,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startFlags, true, options);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return err;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> startActivityLock()主要做了一下几件事: ①处理传进来的参数caller,得到调用者的进程信息,并保存在callerApp变量中,这里就是Launcher应用程序的进程信息了。 ②处理FLAG_ACTIVITY_FORWARD_RESULT标志。该标志的特殊作用,就是能跨Activity传Result,比如A1->A2,A2带该标志启动A3,那么A3调用setResult,然后finish(),结果将直接返回到A1 ③创建一个临时的ActivityRecord对象,该对象只为了后面调用过程中的各种对比,不一定会最终加入到mHistory列表中。 ④判断mPendingActivityLaunches列表是否有等待的Activity要启动,如果有先启动等待的Activity ⑤调用startActivityUncheckedLocked()方法。此时要启动的Activity已经通过检验,被人认为是一个正当的启动请求。 ### 3.2.3(9)创建新的Task 调用ActivityStack.startActivityUncheckedLocked()处理Task问题,因为这里我们是新启动一个apk,所以将创建新的Task,newTask=true,并调用ActivityStack.startActivityLoacked(): <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">privatefinal void startActivityLocked(ActivityRecord r, booleannewTask,</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">boolean doResume, boolean keepCurTransition) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (!newTask) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">…….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Place a new activity at top of stack, so it is next tointeract</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// with the user.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (addPos &lt; 0) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">addPos = NH;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mHistory.add(addPos, r);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.putInHistory();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.frontOfTask = newTask;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (doResume) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">resumeTopActivityLocked(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> 注意AtivityStack中有两个startActivityLoacked()方法,这里调用的是带四个参数的,即startActivityLocked(ActivityRecord r, booleannewTask,boolean doResume, booleankeepCurTransition),其中,r为将要启动的Activity,newTask=true,doResume=true,在这个方法中,将r放到mHistory的最后面doResume=true,所以调用resumeTopActivityLocked(null)。关于Task的概念比较复杂,这里先不讲解。 ### 3.2.4:(10)运行mHistory中最后一个ActivityRecord ActivityStack. resumeTopActivityLocked(null) <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">finalboolean resumeTopActivityLocked(ActivityRecord prev) {</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Find the first activity that is not finishing.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord next = topRunningActivityLocked<wbr style="padding:0px; margin:0px">(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (next == null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// There are no more activities! <wbr style="padding:0px; margin:0px">Let's just startup the</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Launcher...</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mMainStack) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return mService.startHomeActivityLocked();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">next.delayedResume = false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// If the top activity is the resumed one, nothing todo.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mResumedActivity == next &amp;&amp;next.state == ActivityState.RESUMED) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Make sure we have executed any pending transitions, sincethere</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// should be nothing left to do at this point.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.mWindowManager.executeAppTransition();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mNoAnimActivities.clear();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// If we are sleeping, and there is no resumed activity, and thetop</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// activity is paused, well that is the state we want.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if ((mService.mSleeping || mService.mShuttingDown)</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">&amp;&amp; mLastPausedActivity == next&amp;&amp; next.state ==ActivityState.PAUSED) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Make sure we have executed any pending transitions, sincethere</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// should be nothing left to do at this point.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.mWindowManager.executeAppTransition();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mNoAnimActivities.clear();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">returnfalse;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// The activity may be waiting for stop, but that is nolonger</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// appropriate for it.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mStoppingActivities.remove(next);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mGoingToSleepActivities.remove(next);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">next.sleeping = false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mWaitingVisibleActivitie<wbr style="padding:0px; margin:0px">s.remove(next);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mPausingActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: pausing=" +mPausingActivity);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">…..</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// We need to start pausing the current activity so the topone</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// can be resumed...</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mResumedActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: need to startpausing");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startPausingLocked(userLeaving, false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……..</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> 调用resumeTopActivityLocked(null)启动真正的Activity。 ①调用topRunningActivityLocked()方法取出当前正在运行的ActivityRecord对象 ②判断mHistory中是否有记录,如果没有就意味着还没有启动任何的Activity,需要首先调用mService.startHomeActivityLocked()方法启动所谓的“主界面程序”。当然我们这里mHistroy已经有记录了。 ③判断正在执行的Activity是否和目标Activity一样,如果一样,则直接返回。 ④判断当前系统是否处于休眠涨停,如果是,则返回。这里继续往下执行。 ⑤从mStoppingActivities、mWaitingVisibleActivities和mGoingToSleepActivities中删除目标对象,因为接下来将要被启动。 ⑥判断当前是否在暂停某个Activity,如果是则还不能运行。这里mPausingActivity=null,所以继续往下执行。 ⑦判断当前是否有Activity在运行,如果有则先需要暂停当前的Activity。因为我们是在Lancher中启动mainActivity,所以当前mResumedActivity!=null,所有调用startPausingLocked(userLeaving, false); ### 3.2.5(11~16)暂停当前运行Activity ①调用ActivityStack.startPausingLocked()暂停当前Activity。 ②判断运行当前Activity的进程是否存在。在这里 if (prev.app != null&& prev.app.thread !=null)为真。其中,prev.app为记录启动Lancher进程的ProcessRecord,prev.app.thread为Lancher进程的远程调用接口IApplicationThead,所以可以调用prev.app.thread.schedulePauseActivity,到Lancher进程暂停指定Activity。 ③在Lancher进程中消息传递,调用ActivityThread.handlePauseActivity(),最终调用ActivityTHread.performPauseActivity暂停指定Activity。接着通过Binder通信,通知AMS已经完成暂停ActivityManagerNative.getDefault().activityPaused(token). ### 3.2.6(17~20) AMS处理暂停Activity事情 在Launcher通过Binder进程间通信机制通知AMS,它已经准备就绪进入Paused状态,在ActivityStack.completePauseLocked()中完成暂停: <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">private final void completePauseLocked(){</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord prev = mPausingActivity;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_PAUSE) Slog.v(TAG, "Complete pause: " + prev);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (prev != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (prev.finishing) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">prev = finishCurrentActivityLoc<wbr style="padding:0px; margin:0px">ked(prev,FINISH_AFTER_VISIBLE);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else if (prev.app != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (prev.configDestroy) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">destroyActivityLocked(prev, true, false,"pause-config");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mStoppingActivities.add(prev);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mStoppingActivities.size() &gt; 3) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// If we already have a few activities waiting to stop,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// then give up on things going idle and start clearing</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// them out.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_PAUSE) Slog.v(TAG, "To many pending stops, forcingidle");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">scheduleIdleLocked();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">checkReadyForSleepLocked<wbr style="padding:0px; margin:0px">();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_PAUSE) Slog.v(TAG, "App died during pause, not stopping:" + prev);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">prev = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mPausingActivity = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (!mService.isSleeping()) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">resumeTopActivityLocked(prev);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">checkReadyForSleepLocked<wbr style="padding:0px; margin:0px">();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ①给prev赋值mPausingActivity,即上一个被执行的Activity,即Launcer ②如果prev的finishing为true,说明上一个Activity已经完成,因此需要调用finishCurrentActivityLocked()执行相关操作。一般的流程不会为true,这个条件似乎只有内存回收的时候才会被执行。 ③将mPausingActivity变量置为空 ④调用resumeTopActivityLocked方法正式启动目标Activity,即MainActivity ### 3.2.7:(21~23)正式启动目标Activity 调用AcivityStack.resumeTopActivityLocked: <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">final booleanresumeTopActivityLocked(ActivityRecord prev) {</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord next = topRunningActivityLocked<wbr style="padding:0px; margin:0px">(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mResumedActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: need to startpausing");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startPausingLocked(userLeaving, false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (next.app != null &amp;&amp;next.app.thread != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startSpecificActivityLoc<wbr style="padding:0px; margin:0px">ked(next, true, true);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ①该方法在3.2.4步骤中调用过,那时是因为mResumedActivity != null,有Activity正在运行,所以去执行了startPausingLocked暂停Laucher去了。这时候,mResumedActivity=null,所以继续往下执行。 ②判断讲要启动的Activity的客户进程是否存在,这里next.app != null &&next.app.thread != null为false ③调用ActivityStack.startSpecificActivityLocked <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">private final voidstartSpecificActivityLoc<wbr style="padding:0px; margin:0px">ked(ActivityRecord r,</wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">boolean andResume, boolean checkConfig) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Is this activity's application already running?</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ProcessRecord app =mService.getProcessRecordLocked(r.processName,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.info.applicationInfo.uid);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (app != null &amp;&amp; app.thread !=null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">realStartActivityLocked(r, app, andResume, checkConfig);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden; text-indent:112px"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">return;</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.startProcessLocked(r.processName, r.info.applicationInfo,true, 0,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">"activity", r.intent.getComponent(), false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ④客户进程不存在,app!= null && app.thread !=null为false,所以调用mService.startProcessLocked() fork一个新的进程。 ### 3.2.8(24) fork一个新的进程 ①AMS通过Socket通信,向Zygote发送一个创建进程请求,Zygote创建新进程。 ②创建好进程后,调用ActivityThread.main()。到此,我们到了新了一个进程中,也是程序的入口出。 ③调用ActivityThread.attach()开始新的应用程序,接着同过Binder通信通知AMS,新的进程已经创建好了,可以开始新的程序了。 ### 3.2.9(26~28) AMS准备执行目标Activity 目标进程启动后,报告给AMS,自己已经启动完毕可以启动Activity了,这里通过IPC调用AMS的attachApplication方法完成。 ActivityManagerService.attachApplication(): <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">public final voidattachApplication(IApplicationThread thread) {</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">synchronized (this) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">int callingPid = Binder.getCallingPid();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">final long origId = Binder.clearCallingIdentity();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">attachApplicationLocked(thread,callingPid);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">Binder.restoreCallingIdentity(origId);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ①根据Binder.getCallingPid(),或得客户进程pid,并调用attachApplicationLocked(IApplicationThreadthread,int pid) ②在attachApplicationLocked中,根据pid找到对应的ProcessRecord对象,如果找不到说明改pid客户进程是一个没经过AMS允许的进程。 <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">private final booleanattachApplicationLocked(IApplicationThread thread,</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">int pid) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ProcessRecord app;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (pid != MY_PID &amp;&amp; pid&gt;= 0) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">synchronized (mPidsSelfLocked) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app = mPidsSelfLocked.get(pid);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (app == null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">returnfalse;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// If this application record is still attached to aprevious</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// process, clean it up now.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (app.thread != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">handleAppDiedLocked(app, true, true);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.thread = thread;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.curAdj = app.setAdj = -100;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.curSchedGroup = Process.THREAD_GROUP_DEFAULT;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.setSchedGroup =Process.THREAD_GROUP_BG_NONINTERACTIVE;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.forcingToForeground = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.foregroundServices = false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.hasShownUi = false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.debugging = false;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ensurePackageDexOpt(app.instrumentationInfo != null</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">? app.instrumentationInfo.packageName</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">: app.info.packageName);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// See if the top visible activity is waiting to run in thisprocess...</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord hr =mMainStack.topRunningActivityLocked<wbr style="padding:0px; margin:0px">(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (hr != null &amp;&amp; normalMode){</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (hr.app == null &amp;&amp; app.info.uid== hr.info.applicationInfo.uid</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">&amp;&amp;processName.equals(hr.processName)) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mMainStack.realStartActivityLocked(hr, app, true,true))</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ③为ProcessRecordapp对象内部变量赋值 ④确保目标程序(APK)文件已经被转换为了odex文件。Android中安装程序是APK文件,实际上是一个zip文件。 ⑤调用ActivityStack.realStartActivityLocked通知客户进程运行指定Activity. ⑥调用ApplicationThread.scheduleLaunchActivity,启动指定Activity。 ### 3.2.10:(29~35)客户进程启动指定Activity AMS通过IPC通行,通知客户进程启动指定Activity ①调用ApplicationThread.scheduleLaunchActivity ②经过Handler消息传动,调用ActivityThread.handleLaunchActivity() ③调用ActivityThread.performLaunchActivity()完成Activity的加载,并最终调用Activity生命周期的onCreate()方法 ④performLaunchActivity返回,继续调用ActivityThread.handleResumeActivity(),该方法内部又调用ActivityThread.performResumeActivity(),其内部仅仅调用了目标Activity的onResume()方法。到此Activity启动完成。 ⑤添加一个IdleHandler对象,因为在一般情况下,该步骤执行完毕后,Activity就会进入空闲状态,所以就可以进行内存回收。 ### 3.3在已有进程中启动 在已有的进程中启动Activity,也就是在一个应用程序中启动内部Activity,其过程跟3.2小节大致一样,这里我们不会像3.2小节详细分析每一步骤,我们只看差别的地方。这里以启动subActivity为例子。时序图如下: ![](https://box.kancloud.cn/2016-03-16_56e8da7dbf647.jpg) ![](https://box.kancloud.cn/2016-03-16_56e8da7dd58f7.jpg) 以上时序图包含29步骤调用,下面逐一讲解: ### 3.3.1(1~3)在MainActivity启动Activity 这一步跟3.2.1小节一样 ### 3.3.2(4~7) AMS接收客户端startActivity请求 这一步跟3.2.2小节一样 ### 3.3.3(8)不需要创建新的Task 调用ActivityStack.startActivityUncheckedLocked()处理Task问题,因为这里我们是在已有应用中startActivity,也不设置标志要在新的Task中启动Activity,所以不创建新的Task,newTask=false,并调用 ActivityStack.startActivityLoacked(): <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">privatefinal void startActivityLocked(ActivityRecord r, booleannewTask,</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">boolean doResume, boolean keepCurTransition) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (!newTask) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">…….</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Place a new activity at top of stack, so it is next tointeract</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// with the user.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (addPos &lt; 0) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">addPos = NH;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mHistory.add(addPos, r);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.putInHistory();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.frontOfTask = newTask;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (doResume) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">resumeTopActivityLocked(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> 注意AtivityStack中有两个startActivityLoacked()方法,这里调用的是带四个参数的,即startActivityLocked(ActivityRecord r, booleannewTask,boolean doResume, booleankeepCurTransition),其中,r为将要启动的Activity,newTask=false,doResume=true,在这个方法中,将r放到mHistory的最后面doResume=true,所以调用resumeTopActivityLocked(null)。 ### 3.3.4(9)准备启动mHistory中最后一个Activity 这一步跟3.2.4小节一样 ### 3.3.5(10~15)暂停MainActivity 这一步跟3.2.5小节一样 ### 3.3.6(16~19) AMS处理暂停MainActivity 这一步跟3.2.6小节一样 ### 3.3.7(20~22)正式启动目标Activity 调用AcivityStack.resumeTopActivityLocked: <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">final booleanresumeTopActivityLocked(ActivityRecord prev) {</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord next = topRunningActivityLocked<wbr style="padding:0px; margin:0px">(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mResumedActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: need to startpausing");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startPausingLocked(userLeaving, false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (next.app != null &amp;&amp;next.app.thread != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startSpecificActivityLoc<wbr style="padding:0px; margin:0px">ked(next, true, true);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ①调用startSpecificActivityLocked(next, true,true) <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">private final voidstartSpecificActivityLoc<wbr style="padding:0px; margin:0px">ked(ActivityRecord r,</wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">boolean andResume, boolean checkConfig) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Is this activity's application already running?</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ProcessRecord app =mService.getProcessRecordLocked(r.processName,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.info.applicationInfo.uid);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (app != null &amp;&amp; app.thread !=null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">realStartActivityLocked(r, app, andResume, checkConfig);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden; text-indent:112px"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体">return;</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.startProcessLocked(r.processName, r.info.applicationInfo,true, 0,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">"activity", r.intent.getComponent(), false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px; font-family:宋体"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ②subActivity进程已经存在,app != null&& app.thread !=null为true,所以调用realStartActivityLocked。 <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">finalboolean realStartActivityLocked(ActivityRecord r,</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ProcessRecord app, boolean andResume, booleancheckConfig)</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">throws RemoteException {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">…..</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">app.thread.scheduleLaunchActivity(new Intent(r.intent),r.appToken,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">System.identityHashCode(r), r.info,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">new Configuration(mService.mConfiguration),</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">r.compat, r.icicle, results, newIntents,!andResume,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.isNextTransitionForward(), profileFile,profileFd,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">profileAutoStop);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}<wbr style="padding:0px; margin:0px"/></wbr></wbr></wbr></span></p></td></tr></tbody></table> ③调用ApplicationThread.scheduleLaunchActivity,启动指定Activity。 ### 3.3.8(23~29)客户进程启动指定Activity 这一步跟3.2.10是一样的 ### 3.4在已有的ActivityRecord中恢复指定Activity 经过上面3.2和3.3小节,现在对Activity的启动流程应该是比较清晰的了,这一节就简单的讲下恢复Activity的流程。当ActivityRecord已经记录有一个Activity,如果再次调用startActivity,并没有标志要创建Activity新的实例,那么就可以直接恢复该Activity。 ①启动一个Activity,跟前面3.2节一样,都需要暂停当前正在运行的Activity,暂停流程这里就不讲了,完成暂停后,调用ActivityStack.resumeTopActivityLocked()。 ②因为AMS和ActivityTHread的IPC通信,resumeTopActivityLocked会被反复调用几次,每次都会根据一些变量值的差异,走不同的流程。 <table cellspacing="0" cellpadding="0" style="padding:0px; margin:0px auto 10px; font-size:12px; border-collapse:collapse; color:rgb(85,85,85); font-family:宋体,'Arial Narrow',arial,serif"><tbody style="padding:0px; margin:0px"><tr style="padding:0px; margin:0px"><td valign="top" width="568" style="padding:0cm 7px; margin:0px; border:1px solid rgb(0,0,0)"><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px">finalboolean resumeTopActivityLocked(ActivityRecord prev) {</span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Find the first activity that is not finishing.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">ActivityRecord next = topRunningActivityLocked<wbr style="padding:0px; margin:0px">(null);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (mResumedActivity != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Skip resume: need to startpausing");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startPausingLocked(userLeaving, false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (next.app != null &amp;&amp;next.app.thread != null) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">if (DEBUG_SWITCH) Slog.v(TAG, "Resume running: " +next);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">try {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">next.app.thread.scheduleResumeActivity(next.appToken,</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">mService.isNextTransitionForward());</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">checkReadyForSleepLocked<wbr style="padding:0px; margin:0px">();</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"/></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} catch (Exception e) {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">// Whoops, need to restart this activity!</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">startSpecificActivityLoc<wbr style="padding:0px; margin:0px">ked(next, true, false);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">} else {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">……</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">return true;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></span></p><p style="padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:0px; clear:both; height:auto; overflow:hidden"><span lang="EN-US" style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px"><wbr style="padding:0px; margin:0px">}</wbr></wbr></wbr></span></p></td></tr></tbody></table> ③这里,mResumedActivity = null,不走暂停流程。 ④next.app != null &&next.app.thread != null为true,调用ApplicationThead.scheduleResumeActivity(),到客户进程恢复指定Activity。 ⑤经过消息传递,调用ActivityTHread.handleResumeActivity() ⑥调用ActivityTHread.performResumeActivity()正在恢复Activity,接着回调Activity的onResume()方法。 ## 4 stop停止Activity 前面几节汇总,A启动到B时,需要先暂停A,然后再启动B。什么时候停止(stop)或者销毁(Destory)呢? ### 4.1从暂停到停止全过程 ![](https://box.kancloud.cn/2016-03-16_56e8da7deabb2.jpg) 4按Home键回到桌面 5按Back键回到上一个Activity 6长按Home键