{"id":489,"date":"2020-10-09T05:26:54","date_gmt":"2020-10-09T05:26:54","guid":{"rendered":"https:\/\/nurlandroid.com\/?p=489"},"modified":"2021-01-24T12:04:21","modified_gmt":"2021-01-24T12:04:21","slug":"%d0%be%d1%82%d1%80%d0%b8%d1%81%d0%be%d0%b2%d0%ba%d0%b0-%d0%bf%d0%b5%d1%80%d0%b2%d0%be%d0%b3%d0%be-%d0%ba%d0%b0%d0%b4%d1%80%d0%b0-android-%d0%bf%d1%80%d0%b8%d0%bb%d0%be%d0%b6%d0%b5%d0%bd%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/nurlandroid.com\/?p=489","title":{"rendered":"\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430 \u043f\u0440\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438-\u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f Activity \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u0421\u043b\u0435\u0434\u0443\u044f <a href=\"https:\/\/developer.android.com\/topic\/performance\/vitals\/launch-time#cold\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Application.<\/li><li>\u0417\u0430\u043f\u0443\u0441\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430(MainThread aka UiThread).<\/li><li>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e Activity, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435.<\/li><li>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435(\u0440\u0430\u0437\u0434\u0443\u0442\u0438\u0435, inflating) \u0432\u044c\u044e\u0448\u0435\u043a. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u044c\u044e\u0448\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 xml-\u0444\u0430\u0439\u043b\u0435.<\/li><li>\u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432(View.<strong>measure()<\/strong>) \u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f(View.<strong>layout()<\/strong>) \u0432\u044c\u044e\u0448\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/li><li>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/li><\/ol>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u044b\u043b \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440, \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0444\u043e\u043d\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u043d\u0430 Activity \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--PyP1teFw--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/jnpiu0ag9nkzlqcs8bte.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0448\u0430\u0433\u0430\u0445 =)<\/p>\n\n\n\n<p><strong>\u0421\u0442\u0430\u0440\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430<\/strong><\/p>\n\n\n\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityThread.<strong>main()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0439 IPC-\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 ActivityManagerService.<strong>attachApplication()<\/strong> \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <strong>system_server<\/strong>.<\/li><li><strong>system_server<\/strong> \u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0432\u044b\u0437\u043e\u0432 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 ActivityThread.<strong>bindApplication()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0430\u0432\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c <strong>\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 BIND_APPLICATION<\/strong> \u0432 <strong>MessageQueue<\/strong> \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430.<\/li><li>\u041a\u043e\u0433\u0434\u0430 IPC-\u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 &nbsp;ActivityManagerService.<strong>attachApplication()<\/strong> \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, ActivityThread.<strong>main()<\/strong> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Looper.<strong>loop()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430(\u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442) \u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u0432 <strong>MessageQueue<\/strong>.<\/li><li>\u041f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u044d\u0442\u043e <strong>BIND_APPLICATION<\/strong>. \u0412 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 ActivityThread.<strong>handleBindApplication()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 APK \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--jfpc5Xr3--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/fg3caooukxzmcb7kza14.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/strong> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f IPC-\u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 ActivityManagerService.<strong>attachApplication()<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u041f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a Activity<\/strong><\/p>\n\n\n\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <strong>system_server<\/strong> \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 ActivityThread.<strong>bindApplication()<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ActivityManagerService extends IActivityManager.Stub {\n\n  private boolean attachApplicationLocked(\n      IApplicationThread thread, int pid, int callingUid,\n      long startSeq) {\n    thread.bindApplication(...);\n\n    \/\/ See if the top visible activity is waiting to run\n    \/\/  in this process...\n    mAtmInternal.attachApplication(...);\n\n    \/\/ Find any services that should be running in this process...\n    mServices.attachApplicationLocked(app, processName);\n\n    \/\/ Check if a next-broadcast receiver is in this process...\n    if (isPendingBroadcastProcessLocked(pid)) {\n        sendPendingBroadcastsLocked(app);\n    }\n    return true;\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0443 Activity &#8212; mAtmInternal.<strong>attachApplication(&#8230;)<\/strong>. \u041c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 &nbsp;ActivityTaskManagerService.<strong>attachApplication()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 RootActivityContainer.<strong>attachApplication()<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class RootActivityContainer extends ConfigurationContainer {\n\n  boolean attachApplication(WindowProcessController app) {\n    for (ActivityDisplay display : mActivityDisplays) {\n      ActivityStack stack = display.getFocusedStack()\n      ActivityRecord top = stack.topRunningActivityLocked();\n      stack.getAllRunningVisibleActivitiesLocked(mTmpActivityList);\n      for (ActivityRecord activity : mTmpActivityList) {\n        if (activity.app == null\n            &amp;&amp; app.mUid == activity.info.applicationInfo.uid\n            &amp;&amp; app.mName.equals(activity.processName)) {\n          mStackSupervisor.realStartActivityLocked(\n            activity,\n            app,\n            top == activity \/* andResume *\/,\n            true \/* checkConfig *\/\n          )\n        }\n      }\n    }\n    ...\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u041a\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041e\u0431\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0438\u0441\u043f\u043b\u0435\u0439.<\/li><li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0435\u043a \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 Activity \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0438\u0441\u043f\u043b\u0435\u044f.<\/li><li>\u041f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 Activity \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 Activity.<\/li><li>\u0415\u0441\u043b\u0438 Activity \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 ActivityStackSupervisor.<strong>realStartActivityLocked()<\/strong>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <strong>andResume<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>true<\/strong> \u0435\u0441\u043b\u0438 Activity \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u044d\u043a\u0430.<\/li><\/ul>\n\n\n\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 ActivityStackSupervisor.<strong>realStartActivityLocked()<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ActivityStackSupervisor{\n\n  boolean realStartActivityLocked(\n    ActivityRecord r,\n    WindowProcessController proc,\n    boolean andResume,\n    boolean checkConfig\n  ) {\n    ...\n    ClientTransaction clientTransaction = ClientTransaction.obtain(\n            proc.getThread(), r.appToken);\n\n    clientTransaction.addCallback(LaunchActivityItem.obtain(...));\n\n    \/\/ Set desired final state.\n    final ActivityLifecycleItem lifecycleItem;\n    if (andResume) {\n        boolean forward = dc.isNextTransitionForward()\n        lifecycleItem = ResumeActivityItem.obtain(forward);\n    } else {\n        lifecycleItem = PauseActivityItem.obtain();\n    }\n    clientTransaction.setLifecycleStateRequest(lifecycleItem);\n\n    \/\/ Schedule transaction.\n    mService.getLifecycleManager()\n      .scheduleTransaction(clientTransaction);\n    ...\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u0412\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 <strong>system_server<\/strong>. \u041c\u0435\u0442\u043e\u0434 ClientLifecycleManager.<strong>scheduleTransaction()<\/strong>&nbsp;\u0434\u0435\u043b\u0430\u0435\u0442 IPC-\u0432\u044b\u0437\u043e\u0432&nbsp;ActivityThread.<strong>scheduleTransaction()<\/strong>&nbsp;\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442&nbsp;ClientTransactionHandler.<strong>scheduleTransaction()<\/strong>,&nbsp;\u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c&nbsp;\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <code><strong><strong><strong>EXECUTE_TRANSACTION<\/strong><\/strong><\/strong><\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public abstract class ClientTransactionHandler {\n\n    \/** Prepare and schedule transaction for execution. *\/\n    void scheduleTransaction(ClientTransaction transaction) {\n        transaction.preExecute(this);\n        sendMessage(\n          ActivityThread.H.EXECUTE_TRANSACTION,\n          transaction\n        );\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <strong>EXECUTE_TRANSACTION<\/strong> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 TransactionExecutor.<strong>execute()<\/strong>.<\/p>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--lOPFvkgc--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/byzacpqn1gz9h3fo6612.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u043a Activity<\/strong><\/p>\n\n\n\n<p>\u041c\u0435\u0442\u043e\u0434 TransactionExecutor.<strong>execute()<\/strong>&nbsp;\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442&nbsp;TransactionExecutor.<strong>performLifecycleSequence()<\/strong>,&nbsp;\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0432 <strong>ActivityThread<\/strong> \u0434\u043b\u044f&nbsp;\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f(<strong>create<\/strong>), \u0437\u0430\u043f\u0443\u0441\u043a\u0430(<strong>start<\/strong>)&nbsp;\u0438&nbsp;\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f(<strong>resume<\/strong>)&nbsp;Activity:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class TransactionExecutor {\n\n  private void performLifecycleSequence(...) {\n    for (int i = 0, state; i &lt; path.size(); i++) {\n      state = path.get(i);\n      switch (state) {\n        case ON_CREATE:\n          mTransactionHandler.handleLaunchActivity(...);\n          break;\n        case ON_START:\n          mTransactionHandler.handleStartActivity(...);\n          break;\n        case ON_RESUME:\n          mTransactionHandler.handleResumeActivity(...);\n          break;\n        case ON_PAUSE:\n          mTransactionHandler.handlePauseActivity(...);\n          break;\n        case ON_STOP:\n          mTransactionHandler.handleStopActivity(...);\n          break;\n        case ON_DESTROY:\n          mTransactionHandler.handleDestroyActivity(...);\n          break;\n        case ON_RESTART:\n          mTransactionHandler.performRestartActivity(...);\n          break;\n      }\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--97mM7cLH--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/qnl83bka6shtgd3mp3xu.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u041f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440<\/strong><\/p>\n\n\n\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0434\u0443\u0442 \u043a \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>ActivityThread.<strong>handleResumeActivity()<\/strong><\/li><li>WindowManagerImpl.<strong>addView()<\/strong><\/li><li>WindowManagerGlobal.<strong>addView()<\/strong><\/li><li>ViewRootImpl.<strong>setView()<\/strong><\/li><li>ViewRootImpl.<strong>requestLayout()<\/strong><\/li><li>ViewRootImpl.<strong>scheduleTraversals()<\/strong><\/li><li>Choreographer.<strong>postCallback()<\/strong><\/li><li>Choreographer.<strong>scheduleFrameLocked()<\/strong><\/li><\/ul>\n\n\n\n<p>\u041c\u0435\u0442\u043e\u0434 Choreographer.<strong>scheduleFrameLocked()<\/strong> \u0441\u0442\u0430\u0432\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 MSG_DO_FRAME:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--iKD06rqh--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/cj22d0vhnpj8ededlf91.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f&nbsp;<code><strong>MSG_DO_FRAME<\/strong><\/code>&nbsp;\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430&nbsp;Choreographer.<strong>doFrame()<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442&nbsp;ViewRootImpl.<strong>doTraversal()<\/strong>,&nbsp;\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u044b <strong>measure pass<\/strong> \u0438&nbsp;<strong>layout pass<\/strong>, \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u043e\u0445\u043e\u0434&nbsp;<strong>the first draw pass<\/strong>&nbsp;\u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044c\u044e\u0448\u0435\u043a:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--LWIio58J--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/2ken9max4z9flkwlmdmf.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n\n\n\n<p>\u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--PyP1teFw--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/jnpiu0ag9nkzlqcs8bte.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 &#171;\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c&#187;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--t37TW82U--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/00k7kn3bzc1u5rkqhqz5.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u0441 \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0430\u043f\u0430\u0435\u0442 \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-default-filter\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--BgE4Ge2A--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/7fqm484ga67h6x149ajn.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u043b\u043e\u0434\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c! \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438 =)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430 \u043f\u0440\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438-\u0437\u0430\u043f\u0443\u0441\u043a\u0430 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f Activity \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0430\u0434\u0440.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-489","post","type-post","status-publish","format-standard","hentry","category-core"],"_links":{"self":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=489"}],"version-history":[{"count":10,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":512,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions\/512"}],"wp:attachment":[{"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nurlandroid.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}