<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Calvin's Tech Space

    成于堅忍,毀于浮躁

       :: 首頁 :: 聯系 :: 聚合  :: 管理
    啟動activity:
    **android.process.acore進程
    1.Acticity.startActivityForResult()
    2.Instrumention.execStartActivity();
    3.ActivityManagerNative.getDefault()
                    .startActivity()
      3.1 ActivityManagerNative.getDefault()返回的是ActivityManagerProxy的實例,
      它只是一個代理類,這個代理類實際上代理的是IBinder b = ServiceManager.getService("activity");
      這個Service。
      3.2 這個Service是什么時候添加進來的呢?
      在SystemServer.java的run()中有調用
      ActivityManagerService.setSystemProcess();
          ServiceManager.addService("activity", m);
          這里還會添加許多系統關鍵服務。
          (TODO:查看在SystemServer的Log輸出)
         
    **system_process進程
    4 ActivityManagerNative
        |--ActivityManagerService
       
        在ActivityManagerNative的onTransact方法中最終提供了服務:
        case START_ACTIVITY_TRANSACTION:
          ActivityManagerService.startActivity();
            --startActivityLocked(IApplicationThread caller,
                Intent intent, String resolvedType,
                Uri[] grantedUriPermissions,
                int grantedMode, ActivityInfo aInfo, IBinder resultTo,
                String resultWho, int requestCode,
                int callingPid, int callingUid, boolean onlyIfNeeded,
                boolean componentSpecified)
              --startActivityUncheckedLocked(r, sourceRecord,
                    grantedUriPermissions, grantedMode, onlyIfNeeded, true)
              在這個方法里面檢查權限,解析intent中的Flag。。。
              --startActivityLocked(HistoryRecord r, boolean newTask)
                --resumeTopActivityLocked(HistoryRecord prev)
                  --startSpecificActivityLocked(HistoryRecord r,boolean andResume, boolean checkConfig)
                    --startProcessLocked(String processName,ApplicationInfo info, boolean knownToBeDead, int intentFlags,String hostingType, ComponentName hostingName)
                      --startProcessLocked(ProcessRecord app,String hostingType, String hostingNameStr)
                        在這里啟動一個進程用來host這個應用
                        int pid = Process.start("android.app.ActivityThread",
                        mSimpleProcessManagement ? app.processName : null, uid, uid,
                        gids, debugFlags, null);
                       
    ActivityManagerService.java
    --startSpecificActivityLocked(HistoryRecord r,boolean andResume, boolean checkConfig)
      --realStartActivityLocked(HistoryRecord r,ProcessRecord app, boolean andResume, boolean checkConfig)
        --app.thread.scheduleLaunchActivity                                   //scheduleLaunchActivity()@IApplicationThread.java
          --scheduleLaunchActivity()@ActivityThread.java                      //這里實際是ApplicationThreadNative提供的服務
            --handleMessage()@H$ActivityThread.java
              --handleLaunchActivity()@ActivityThread.java
                --Activity performLaunchActivity(ActivityRecord r, Intent customIntent)@ActivityThread.java  //這時真正的Activity對象被構造出來
                  --mInstrumentation.newActivity()                            //通過反射構造出Activity對象
                  --activity.attach()                                         //初始化Activity,生成一個window對象,設置各種狀態等等
                  --mInstrumentation.callActivityOnCreate(activity, r.state);  //調用Activity的onCreate()方法
               
                  到這里,我們自己寫的activity的onCreate()方法已經被系統調用了,接下來依次回調生命周期方法:
                  --activity.performStart();
                    --mInstrumentation.callActivityOnStart(this);
                  --mInstrumentation.callActivityOnRestoreInstanceState(activity, r.state);
                  --mInstrumentation.callActivityOnPostCreate(activity, r.state);
                  --mActivities.put(r.token, r);                               //將這個activity入棧
                 
                然后就要調用onResume()方法了:
                --handleResumeActivity(IBinder token, boolean clearHide, boolean isForward)
                  --performResumeActivity(token, clearHide);
                    --r.activity.performResume();
                      --performRestart()@Activity.java;
                        --mInstrumentation.callActivityOnRestart(this);
                        --mInstrumentation.callActivityOnStart(this);
                    --mInstrumentation.callActivityOnResume(this);
                    onResume()已經調用完畢,一個activity的邏輯處理結束了,但是這時候屏幕上還不會顯示任何東西,因為View還沒有添加進去
                   
                   
                  --r.window.getDecorView();                                   //開始把DecorView添加進Window
                  --wm.addView(decor, l);
               
                至此一個Activity啟動結束。
    posted on 2010-11-23 14:59 calvin 閱讀(4220) 評論(1)  編輯  收藏 所屬分類: Android

    Feedback

    # re: [原]Activity啟動過程分析 2011-07-08 21:26 mark in working
    寫的很好,向您學習!  回復  更多評論
      

    主站蜘蛛池模板: 亚洲AV无码专区国产乱码电影| 亚洲国产天堂久久久久久| 亚洲福利视频一区| 日韩免费高清播放器| 亚洲精品无码av人在线观看| 岛国精品一区免费视频在线观看| 国产亚洲精品精品国产亚洲综合 | 破了亲妺妺的处免费视频国产| 亚洲一级免费视频| 在线免费观看一级毛片| 亚洲欧美国产国产一区二区三区| 永久黄网站色视频免费观看| 麻豆亚洲AV成人无码久久精品 | 亚洲欧洲日韩不卡| 99re在线视频免费观看| 亚洲1234区乱码| 国产免费人成视频在线观看| 一区二区在线免费视频| 久久亚洲精品成人综合| 四虎在线免费视频| 国产精品亚洲专区在线播放| 亚洲午夜未满十八勿入网站2| 无码成A毛片免费| 亚洲AV日韩综合一区尤物| 亚洲精品成人网久久久久久| 大地资源中文在线观看免费版| 亚洲明星合成图综合区在线| 精品久久洲久久久久护士免费| 韩国免费a级作爱片无码| 91在线精品亚洲一区二区| 韩国欧洲一级毛片免费| 中文字幕乱理片免费完整的| 中文字幕亚洲精品| 国产成人免费片在线观看| 无码A级毛片免费视频内谢| 亚洲av色香蕉一区二区三区| 亚洲产国偷V产偷V自拍色戒| 成人免费毛片视频| 四虎国产精品免费永久在线| 亚洲中文字幕无码久久2020| 国产成人亚洲精品狼色在线|