2011-9-27 22:05:52

 


2011-9-27 22:05:52


 Step 4. Instrumentation.execStartActivity
         這個函數定義在frameworks/base/core/java/android/app/Instrumentation.java文件中:


public class Instrumentation {

 ......

 public ActivityResult execStartActivity(
 Context who, IBinder contextThread, IBinder token, Activity target,
 Intent intent, int requestCode) {
  IApplicationThread whoThread = (IApplicationThread) contextThread;
  if (mActivityMonitors != null) {
   ......
  }
  try {
   int result = ActivityManagerNative.getDefault()
    .startActivity(whoThread, intent,
    intent.resolveTypeIfNeeded(who.getContentResolver()),
    null, 0, token, target != null ? target.mEmbeddedID : null,
    requestCode, false, false);
   ......
  } catch (RemoteException e) {
  }
  return null;
 }

 ......

}         這裏的ActivityManagerNative.getDefault返回ActivityManagerService的遠程接口,即ActivityManagerProxy接口,

具體可以參考Android系統在新進程中啓動自定義服務過程(startService)的原理分析一文。

         這裏的intent.resolveTypeIfNeeded返回這個intent的MIME類型,在這個例子中,沒有AndroidManifest.xml設置MainActivity的MIME類型,因此,這裏返回null。

         這裏的target不爲null,但是target.mEmbddedID爲null,我們不用關注。

 

發佈了363 篇原創文章 · 獲贊 11 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章