{"id":421,"date":"2022-11-28T16:42:32","date_gmt":"2022-11-28T08:42:32","guid":{"rendered":"https:\/\/iichen.cn\/?p=421"},"modified":"2022-11-28T16:42:32","modified_gmt":"2022-11-28T08:42:32","slug":"android-context%e3%80%81window%e5%9f%ba%e7%a1%80%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/iichen.cn\/?p=421","title":{"rendered":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790"},"content":{"rendered":"<h5>1. Context<\/h5>\n<blockquote><p>\n  Context\u662f\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7cfb\u7edf\u4e4b\u95f4\u6c9f\u901a\u7684\u6865\u6881\uff0c\u662f\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u7cfb\u7edf\u8d44\u6e90\u7684\u63a5\u53e3\n<\/p><\/blockquote>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.csdn.net\/weixin_43766753\/article\/details\/109017196\" title=\"Context\u6e90\u94fe\u63a5\">Context\u6587\u7ae0\u6e90\u94fe\u63a5<\/a><br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png'><img class=\"lazyload lazyload-style-11\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/a><\/p>\n<ul>\n<li>\u4f7f\u7528\u5230\u4e86\u88c5\u9970\u8005\u6a21\u5f0f\uff0c\u628a\u5c01\u88c5\u64cd\u4f5c\u5b9e\u73b0\u5728ContextImpl\u4e2d\u3002<\/li>\n<li>ContextProvider\u4f7f\u7528\u7684\u662fApplication\u7684context\uff0cBroadcast\u4f7f\u7528\u7684\u662factivity\u7684context<\/li>\n<li>Activity\u7684getBaseContext\uff0c\u5373ContextImpl \u771f\u6b63\u7684Context\u63a5\u53e3\u7684\u903b\u8f91\u5b9e\u73b0\u7c7b<\/li>\n<li>\u4f7f\u7528Application\u542f\u52a8\u7684Activity\u5fc5\u987b\u6307\u5b9atask\u4ee5\u53ca\u6807\u8bb0\u4e3asingleTask\uff0c\u56e0\u4e3aApplication\u662f\u6ca1\u6709\u4efb\u52a1\u6808\u7684\uff0c\u9700\u8981\u91cd\u65b0\u5f00\u4e00\u4e2a\u65b0\u7684\u4efb\u52a1\u6808<\/li>\n<li>Application\u521b\u5efa\uff1a(\u7c7b\u52a0\u8f7d\u548c\u53cd\u5c04)\n<ol>\n<li>ActivityThread\u7c7b -> performLaunchActivity\u65b9\u6cd5\u5185\u7684 makeApplication<\/li>\n<li>LoadedApk\u7c7b -> makeApplication\u65b9\u6cd5\u5185<br \/>\n2.1 ContextImpl.createAppContext        \u521b\u5efaContextImpl\u5b9e\u4f8b<br \/>\n2.2 mActivityThread.mInstrumentation.newApplication  \u521b\u5efaApplication<br \/>\n2.3 ContextImpl.setOuterContext(app); \u5c06Application\u8d4b\u503c\u7ed9ContextImpl<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p>**<\/p>\n<p style='color:green'>\u4ee5\u4e0b\u90fd\u662f\u76f8\u5173\u901a\u8fc7attach\u9644\u52a0<\/p>\n<p>**<\/p>\n<pre><code class=\"language-java line-numbers\">Instrumentation.class(api29)\n\/\/ \u8fd9\u91cc\u7684context \u5c31\u662fContextImpl\npublic Application newApplication(ClassLoader cl, String className, Context context)\n        throws InstantiationException, IllegalAccessException,\n        ClassNotFoundException {\n    Application app = getFactory(context.getPackageName())\n            .instantiateApplication(cl, className);\n    app.attach(context);\n    return app;\n}\n\nApplication.class(api29)\nfinal void attach(Context context) {\n    attachBaseContext(context);\n    mLoadedApk = ContextImpl.getImpl(context).mPackageInfo;\n}\n\nContextWrapper.class(api29)\nContext mBase;\nprotected void attachBaseContext(Context base) {\n    if (mBase != null) {\n        throw new IllegalStateException(\"Base context already set\");\n    }\n    mBase = base;\n}\n<\/code><\/pre>\n<ul>\n<li>Activity\u521b\u5efa (\u7c7b\u52a0\u8f7d\u548c\u53cd\u5c04)\n<ol>\n<li>ActivityThread\u7c7b -> handleLaunchActivity\u65b9\u6cd5\u5185\u7684 performLaunchActivity<\/li>\n<li>performLaunchActivity\u65b9\u6cd5\u5185\uff1amInstrumentation.newActivity\u3001r.packageInfo.makeApplication(\u540c\u4e0a)<\/li>\n<\/ol>\n<\/li>\n<li>Service\u521b\u5efa (\u7c7b\u52a0\u8f7d\u548c\u53cd\u5c04)\n<ol>\n<li>ActivityThread\u7c7b > handleCreateService\u65b9\u6cd5<\/li>\n<li>\u7c7b\u52a0\u8f7d\u548c\u53cd\u5c04\u521b\u5efaservice\uff0c\u968f\u540e\u521b\u5efaContextImpl\uff0c\u5e76\u540c\u4e0a\u8bc9<strong>\u4e00\u6837\u8c03\u7528attach<\/strong><\/li>\n<\/ol>\n<\/li>\n<li>BroadCast\u521b\u5efa\n<ul>\n<li>ContextImple\u7c7b -> registerReceiver\u65b9\u6cd5 -> registerReceiverInternal<\/li>\n<li>registerReceiverInternal -> ReceiverDispatcher\u4e2d\u6709\u4e2aInnerReceiver(Receiver\u662f\u6ca1\u6709\u8de8\u8fdb\u7a0b\u901a\u4fe1\u80fd\u529b\u7684\uff0c\u800c\u5e7f\u64ad\u9700\u8981AMS\u7684\u8c03\u63a7,InnerReceiver\u662f\u7ef4\u62a4\u8054\u7cfb\u7684)<\/li>\n<li>registerReceiverInternal\u7684\u53c2\u6570 getOuterContext() \u83b7\u53d6\u7684\u5c31\u662f\u521b\u5efa\u5e7f\u64ad\u7684\u4e0a\u4e0b\u6587Context\uff0c\u4e00\u822c\u90fd\u662f\u5728Activity\u5185\u521b\u5efa\uff0c\u6240\u4ee5\u8fd9\u4e2aContext\u4e00\u822c\u90fd\u662fActivity\u3002<\/li>\n<\/ul>\n<\/li>\n<li>ContextProvider\u521b\u5efa\n<ol>\n<li>ActivityThread\u7c7b > handleBindApplication\u65b9\u6cd5 installContentProviders<\/li>\n<li>installContentProviders\u65b9\u6cd5 installProvider<br \/>\n2.1 localProvider.getIContentProvider() \u521b\u5efaContentProvider<br \/>\n2.2 \u8c03\u7528attachInfo \u5c06 Context\u7b49\u76f8\u5173\u4fe1\u606f\u9644\u52a0<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h5>2. Window<\/h5>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/blog.csdn.net\/weixin_43766753\/article\/details\/108350589\" title=\"Window\u539f\u6587\u7ae0\u94fe\u63a5\">Window\u539f\u6587\u7ae0\u94fe\u63a5<\/a><br \/>\n &#8211; viewRootImpl\u662fwindow\u548cview\u4e4b\u95f4\u7684\u6865\u6881\uff0cviewRootImpl\u53ef\u4ee5\u5904\u7406\u4e24\u8fb9\u7684\u5bf9\u8c61\uff0c\u7136\u540e\u8054\u7ed3\u8d77\u6765<br \/>\n    1. setView\u65b9\u6cd5\u5185\u7684 mWindowSession\u662f\u4e00\u4e2aAIDL\uff0c\u53ef\u4ee5\u8c03\u7528WMS\u65b9\u6cd5<\/p>\n<pre><code class=\"language-java line-numbers\">\/\/ \u4e00\u4e2a\u5e94\u7528\u53ea\u6709\u4e00\u4e2aIWindowSession\u5355\u4f8b\u3002\npublic static IWindowSession getWindowSession() {\n synchronized (WindowManagerGlobal.class) {\n     if (sWindowSession == null) {\n         try {\n             ...\n             sWindowSession = windowManager.openSession(\n                     new IWindowSessionCallback.Stub() {\n                         ...\n                     });\n         } \n         ...\n     }\n     return sWindowSession;\n }\n}\n\n<\/code><\/pre>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/s1.ax1x.com\/2020\/08\/26\/dfGICn.png\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/s1.ax1x.com\/2020\/08\/26\/dfGICn.png'><img class=\"lazyload lazyload-style-11\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/s1.ax1x.com\/2020\/08\/26\/dfGICn.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/a><\/p>\n<blockquote><p>\n  window\u7684\u6dfb\u52a0\u8fc7\u7a0b\u662f\u901a\u8fc7PhoneWindow\u5bf9\u5e94\u7684WindowManagerImpl\u6765\u6dfb\u52a0window\uff0c\u5185\u90e8\u4f1a\u8c03\u7528WindowManagerGlobal\u6765\u5b9e\u73b0\u3002WindowManagerGlobal\u4f1a\u4f7f\u7528viewRootImpl\u6765\u8fdb\u884c\u8de8\u8fdb\u7a0b\u901a\u4fe1\u8ba9WMS\u6267\u884c\u521b\u5efawindow\u7684\u4e1a\u52a1\u3002<br \/>\n  \u6bcf\u4e2a\u5e94\u7528\u90fd\u6709\u4e00\u4e2awindowSession\uff0c\u7528\u4e8e\u8d1f\u8d23\u548cWMS\u7684\u901a\u4fe1\uff0c\u5982ApplicationThread\u4e0eAMS\u7684\u901a\u4fe1\u3002<br \/>\n  &#8211; PhoneWindow\u672c\u8eab\u4e0d\u662f\u771f\u6b63\u610f\u4e49\u4e0a\u7684window\uff0c\u4ed6\u66f4\u591a\u53ef\u4ee5\u8ba4\u4e3a\u662f\u8f85\u52a9Activity\u64cd\u4f5cwindow\u7684\u5de5\u5177\u7c7b\u3002<br \/>\n  &#8211; windowManagerImpl\u5e76\u4e0d\u662f\u7ba1\u7406window\u7684\u7c7b\uff0c\u800c\u662f\u7ba1\u7406PhoneWindow\u7684\u7c7b\u3002\u771f\u6b63\u7ba1\u7406window\u7684\u662fWMS\u3002<br \/>\n  &#8211; PhoneWindow\u53ef\u4ee5\u914d\u5408DecorView\u53ef\u4ee5\u7ed9\u5176\u4e2d\u7684window\u6309\u7167\u4e00\u5b9a\u7684\u903b\u8f91\u63d0\u4f9b\u6807\u51c6\u7684UI\u7b56\u7565<br \/>\n  &#8211; PhoneWindow\u9650\u5236\u4e86\u4e0d\u540c\u7684\u7ec4\u4ef6\u6dfb\u52a0window\u7684\u6743\u9650\uff08\u5185\u90e8\u6709\u4e00\u4e2atoken\u5c5e\u6027\uff09\u3002\n<\/p><\/blockquote>\n<h6>2.1 Activity\u7684Window\u521b\u5efa<\/h6>\n<ul>\n<li>Activity\u4e2d\u4f7f\u7528getWindowManager\u65b9\u6cd5\u83b7\u53d6\u5230\u7684\u5c31\u662f\u5e94\u7528\u7684PhoneWindow\u5bf9\u5e94\u7684WindowManagerImpl\n<ol>\n<li>attach\u65b9\u6cd5\u5185\u521b\u5efa\u4e86PhoneWindow\uff0c\u5e76mWindow.setWindowManager \u5c06PhoneWindow\u548cWindowManager\u7ed1\u5b9a<\/li>\n<li>setWindowManager\u65b9\u6cd5\u5185 \u8bbe\u7f6emAppToken\uff0c\u521b\u5efamWindowManager\uff08WindowManagerImpl\uff09<\/li>\n<li>attach\u540e\u4f1a\u56de\u8c03onCreate\u65b9\u6cd5\uff0conCreate\u5185\u4f1a\u751f\u6210DecorView\u5e76\u8bbe\u7f6e\u76f8\u5173\u7684\u5e03\u5c40<\/li>\n<li>ActivityThread\u7684handleResumeActivity\u65b9\u6cd5\u4e2d \u4f1a\u56de\u8c03Activity\u7684onResume\u65b9\u6cd5\uff0c\u800conResume\u65b9\u6cd5\u5185\u5c31\u5305\u542b\u4e86 WindowManager.addView \u5c06DecorView\u6dfb\u52a0\u5230\u89c6\u56fe\u4e0a<br \/>\n>\u521b\u5efaPhoneWindow -> \u521b\u5efaWindowManager -> \u521b\u5efadecorView -> \u5229\u7528windowManager\u628aDecorView\u663e\u793a\u5230\u5c4f\u5e55\u4e0a<br \/>\n>\u56de\u8c03onResume\u65b9\u6cd5\u7684\u65f6\u5019\uff0cDecorView\u8fd8\u6ca1\u6709\u88ab\u6dfb\u52a0\u5230\u5c4f\u5e55\uff0c\u6240\u4ee5\u5f53onResume\u88ab\u56de\u8c03\uff0c\u6307\u7684\u662f\u5c4f\u5e55\u5373\u5c06\u5230\u663e\u793a\uff0c\u800c\u4e0d\u662f\u5df2\u7ecf\u663e\u793a<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h6>2.2 PopupWindow\u7684Window\u521b\u5efa<\/h6>\n<ul>\n<li>\u6839\u636e\u53c2\u6570\u6784\u5efapopupDecorView<\/li>\n<li>\u628apopupDecorView\u6dfb\u52a0\u5230\u5c4f\u5e55\u4e0a<\/li>\n<\/ul>\n<h6>2.3 Dialog\u7684Window\u521b\u5efa (\u4e0eActivity\u7c7b\u4f3c)<\/h6>\n<ul>\n<li>dialog\u548cpopupWindow\u4e0d\u540c\uff0cdialog\u521b\u5efa\u4e86\u65b0\u7684PhoneWindow\uff0c\u4f7f\u7528\u4e86PhoneWindow\u7684DecorView\u6a21\u677f\u3002\u800cpopupWindow\u6ca1\u6709<\/li>\n<li>dialog\u7684\u663e\u793a\u5c42\u7ea7\u6570\u66f4\u9ad8\uff0c\u4f1a\u76f4\u63a5\u663e\u793a\u5728Activity\u4e0a\u9762\uff0c\u5728dialog\u540e\u6dfb\u52a0\u7684popUpWindow\u4e5f\u4f1a\u663e\u793a\u5728dialog\u4e0b<\/li>\n<\/ul>\n<h6>2.4 \u603b\u7ed3<\/h6>\n<ul>\n<li>PhoneWindows\u548cWindowManagerImpl<\/li>\n<li>\u6dfb\u52a0View => WindowManagerGlobal\u83b7\u53d6Session\uff0c\u521b\u5efa\u4e00\u4e2aViewRootImpl\u53bb\u8bbf\u95eeWMS\uff0c\u5728\u4f7f\u7528ViewRootImpl\u53bb\u7ed8\u5236View\u3002   WindowManagerImpl\u5185\u90e8\u6301\u6709WindowManagerGlobal\u8fd9\u6837\u5c31\u7b80\u5355\u6613\u64cd\u4f5c<\/li>\n<li>PhoneWindow\u53ea\u662f\u5bf9Window\u7684\u5c01\u88c5\uff0c\u5185\u90e8\u6301\u6709DecorView\uff0c\u5e76\u53ef\u4ee5\u901a\u8fc7ViewRootImpl\u8fdbView\u7684\u64cd\u4f5c<\/li>\n<li>PhoneWindow\u5185\u90e8\u53ea\u6301\u6709\u4e00\u4e2adecorView\uff0c\u53ea\u7ba1\u7406\u4e00\u4e2aview \u6811\uff0c\u5e76\u4e0d\u662fwindow \u5bb9\u5668\uff1bPhoneWindow\u53ea\u662f\u63d0\u4f9b\u4e86 token \u673a\u5236\u6765\u6821\u9a8c\u5b50window\u7684\u5408\u6cd5\u6027<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. Context Context\u662f\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7cfb\u7edf\u4e4b\u95f4\u6c9f\u901a\u7684\u6865\u6881\uff0c\u662f\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u7cfb\u7edf\u8d44\u6e90\u7684\u63a5\u53e3 Contex [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,8],"tags":[],"class_list":["post-421","post","type-post","status-publish","format-standard","hentry","category-android","category-8"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/iichen.cn\/?p=421\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen\" \/>\n<meta property=\"og:description\" content=\"1. Context Context\u662f\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7cfb\u7edf\u4e4b\u95f4\u6c9f\u901a\u7684\u6865\u6881\uff0c\u662f\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u7cfb\u7edf\u8d44\u6e90\u7684\u63a5\u53e3 Contex [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/iichen.cn\/?p=421\" \/>\n<meta property=\"og:site_name\" content=\"IIchen\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-28T08:42:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\" \/>\n<meta name=\"author\" content=\"iichen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"iichen\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/iichen.cn\/?p=421#article\",\"isPartOf\":{\"@id\":\"https:\/\/iichen.cn\/?p=421\"},\"author\":{\"name\":\"iichen\",\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"headline\":\"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790\",\"datePublished\":\"2022-11-28T08:42:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/iichen.cn\/?p=421\"},\"wordCount\":214,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"image\":{\"@id\":\"https:\/\/iichen.cn\/?p=421#primaryimage\"},\"thumbnailUrl\":\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\",\"articleSection\":[\"Android\",\"\u7b14\u8bb0\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/iichen.cn\/?p=421#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/iichen.cn\/?p=421\",\"url\":\"https:\/\/iichen.cn\/?p=421\",\"name\":\"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen\",\"isPartOf\":{\"@id\":\"https:\/\/iichen.cn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/iichen.cn\/?p=421#primaryimage\"},\"image\":{\"@id\":\"https:\/\/iichen.cn\/?p=421#primaryimage\"},\"thumbnailUrl\":\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\",\"datePublished\":\"2022-11-28T08:42:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/iichen.cn\/?p=421#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/iichen.cn\/?p=421\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/iichen.cn\/?p=421#primaryimage\",\"url\":\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\",\"contentUrl\":\"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/iichen.cn\/?p=421#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/iichen.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/iichen.cn\/#website\",\"url\":\"https:\/\/iichen.cn\/\",\"name\":\"IIchen\",\"description\":\"Just do it!\",\"publisher\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/iichen.cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c\",\"name\":\"iichen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg\",\"contentUrl\":\"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg\",\"width\":940,\"height\":940,\"caption\":\"iichen\"},\"logo\":{\"@id\":\"https:\/\/iichen.cn\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/www.iichen.cn\"],\"url\":\"https:\/\/iichen.cn\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/iichen.cn\/?p=421","og_locale":"zh_CN","og_type":"article","og_title":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen","og_description":"1. Context Context\u662f\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7cfb\u7edf\u4e4b\u95f4\u6c9f\u901a\u7684\u6865\u6881\uff0c\u662f\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u7cfb\u7edf\u8d44\u6e90\u7684\u63a5\u53e3 Contex [&hellip;]","og_url":"https:\/\/iichen.cn\/?p=421","og_site_name":"IIchen","article_published_time":"2022-11-28T08:42:32+00:00","og_image":[{"url":"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png","type":"","width":"","height":""}],"author":"iichen","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"iichen"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/iichen.cn\/?p=421#article","isPartOf":{"@id":"https:\/\/iichen.cn\/?p=421"},"author":{"name":"iichen","@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"headline":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790","datePublished":"2022-11-28T08:42:32+00:00","mainEntityOfPage":{"@id":"https:\/\/iichen.cn\/?p=421"},"wordCount":214,"commentCount":0,"publisher":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"image":{"@id":"https:\/\/iichen.cn\/?p=421#primaryimage"},"thumbnailUrl":"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png","articleSection":["Android","\u7b14\u8bb0"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/iichen.cn\/?p=421#respond"]}]},{"@type":"WebPage","@id":"https:\/\/iichen.cn\/?p=421","url":"https:\/\/iichen.cn\/?p=421","name":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790 - IIchen","isPartOf":{"@id":"https:\/\/iichen.cn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/iichen.cn\/?p=421#primaryimage"},"image":{"@id":"https:\/\/iichen.cn\/?p=421#primaryimage"},"thumbnailUrl":"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png","datePublished":"2022-11-28T08:42:32+00:00","breadcrumb":{"@id":"https:\/\/iichen.cn\/?p=421#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/iichen.cn\/?p=421"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/iichen.cn\/?p=421#primaryimage","url":"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png","contentUrl":"https:\/\/s1.ax1x.com\/2020\/10\/10\/06GYuD.png"},{"@type":"BreadcrumbList","@id":"https:\/\/iichen.cn\/?p=421#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/iichen.cn\/"},{"@type":"ListItem","position":2,"name":"Android-Context\u3001Window\u57fa\u7840\u89e3\u6790"}]},{"@type":"WebSite","@id":"https:\/\/iichen.cn\/#website","url":"https:\/\/iichen.cn\/","name":"IIchen","description":"Just do it!","publisher":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/iichen.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/iichen.cn\/#\/schema\/person\/4a47edf85ab49841df9e8f6aee40b77c","name":"iichen","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/iichen.cn\/#\/schema\/person\/image\/","url":"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg","contentUrl":"https:\/\/iichen.cn\/wp-content\/uploads\/2025\/01\/avatar.jpg","width":940,"height":940,"caption":"iichen"},"logo":{"@id":"https:\/\/iichen.cn\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.iichen.cn"],"url":"https:\/\/iichen.cn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts\/421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=421"}],"version-history":[{"count":0,"href":"https:\/\/iichen.cn\/index.php?rest_route=\/wp\/v2\/posts\/421\/revisions"}],"wp:attachment":[{"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iichen.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}