下载此文档

Android Activity的启动过程.doc


文档分类:IT计算机 | 页数:约20页 举报非法文档有奖
1/20
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/20 下载此文档
文档列表 文档介绍
Android Activity的启动过程
Activity的启动过程真的很复杂,先看一张图大概了解一下,其中用灰色背景框起来的是在同一个类的方法,如下图:
那接下来就从源码的角度来分析Activity的启动过程。
当然是从Activity的startActivity方法开始的,
***@Override
public void startActivity(Intent intent) {
(intent, null);
}
使用this关键字调用了startActivity方法的两个参数的重载。如下:
***@Override
public void startActivity(Intent intent, ***@Nullable Bundle options) {
if (options != null) {
startActivityForResult(intent, -1, options);
} else {
// Note we want to go through this call patibility with
// applications that may have overridden the method.
startActivityForResult(intent, -1);
}
}
不管怎样,都会调用startActivityForResult方法。并将intent传进。
public void startActivityForResult(Intent intent, int requestCode) {
startActivityForResult(intent, requestCode, null);
}
转到了startActivityForResult三个参数的重载方法,那就跟进瞧瞧,源码如下:
public void startActivityForResult(Intent intent, int requestCode, ***@Nullable Bundle options) {
if (mParent == null) {
ar =
(
this, (), mToken, this,
intent, requestCode, options);
if (ar != null) {
(
mToken, mEmbeddedID, requestCode, (),
());
}
if (requestCode >= 0) {
// If this start is requesting a result, we can avoid making
// the activity visible until the result is received. Setting
// this code during onCreate(Bundle savedInstanceState) or onResume() will keep the
// activity hidden during this time, to avoid flickering.
// This can only be done when a result is requested because
// that guarantees we will get information back when the
// activity is finished, no matter what happens to it.
mStartedActivity = true;
}
cancelInputsAndStartExitTransition(options);
// TODO Consider clearing/flushing other event sources and events for child windows.
} else {
if (options != null) {
(this, intent, requestCode, options);
}

Android Activity的启动过程 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数20
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小289 KB
  • 时间2017-12-19