@Override public void startActivity(Intent intent) { this.startActivity(intent, null); } @Override publicvoidstartActivity(Intent intent, @Nullable Bundle options) { if (options != null) { startActivityForResult(intent, -1, options); } else { // Note we want to go through this call for compatibility with // applications that may have overridden the method. startActivityForResult(intent, -1); } }
publicvoid startActivityForResult(@RequiresPermission Intent intent, int requestCode, @Nullable Bundle options) { if (mParent == null) { //数据进行转换 新加入的 options = transferSpringboardActivityOptions(options); //启动新的Activity,核心在mMainThread.getApplicationThread()中完成 Instrumentation.ActivityResult ar = mInstrumentation.execStartActivity( this, mMainThread.getApplicationThread(), mToken, this, intent, requestCode, options); if (ar != null) { mMainThread.sendActivityResult( mToken, mEmbeddedID, requestCode, ar.getResultCode(), ar.getResultData()); } 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) { mParent.startActivityFromChild(this, intent, requestCode, options); } else { // Note we want to go through this method for compatibility with // existing applications that may have overridden it. mParent.startActivityFromChild(this, intent, requestCode); } } }
这里出现了mParent的判断,那么我们就找到这个值的说明,如下
1 2 3 4 5 6 7 8 9
/** Is this activity embedded inside of another activity? */ publicfinalbooleanisChild(){ return mParent != null; }
/** Return the parent activity if this view is an embedded child. */ publicfinal Activity getParent(){ return mParent; }