{"id":41,"date":"2015-06-17T06:58:06","date_gmt":"2015-06-17T06:58:06","guid":{"rendered":"https:\/\/boochlin.com\/?p=41"},"modified":"2015-06-17T07:12:46","modified_gmt":"2015-06-17T07:12:46","slug":"android-%e5%af%a6%e4%bd%9c-datacontrol-%e5%88%86%e9%9b%a2-createpackagecontext","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=41","title":{"rendered":"Android \u5be6\u4f5c data\/control  \u5206\u96e2 &#8211; createPackageContext()"},"content":{"rendered":"<p>\u4e00\u96bb\u5beb\u597d\u7684android app \u6700\u4f73\u60c5\u6cc1\u4e0b\uff0c\u4f60\u6703\u5e0c\u671b\u4e0d\u7ba1porting \u5230\u54ea\u4e00\u53f0\u6a5f\u5668\u90fd\u80fd\u5403\u904d\u5929\u4e0b\u7121\u6575\u624b<br \/>\n\u9019\u807d\u8d77\u4f86\u5f88\u50cf\u5ee2\u8a71\uff0c\u4f46\u662f\u5176\u5be6\u641e\u8d77\u4f86\u4e0d\u662f\u96a8\u96a8\u4fbf\u4fbf\u7684<br \/>\n\u5149\u662f\u4e00\u822cthird app \u5c31\u8981\u6ce8\u610f\u5404\u7a2edpi\u7684\u5c0d\u61c9\uff0c\u4ee5\u53ca\u8a9e\u7cfb\u7684\u5c0d\u61c9\uff08\u963f\u62c9\u4f2f\u8a9e\u662f\u5f9e\u53f3\u908a\u958b\u59cb\u7684\u5594\uff09<br \/>\n\u4f46\u662f\u9019\u4e0d\u662f\u6b64\u6587\u7684\u91cd\u9ede<\/p>\n<p><span style=\"color: #ff0000;\">\u672c\u6587\u9019\u6b21\u91cd\u9ede\u662f\u5982\u4f55 \u00a0customize app by access other app\u00a0<\/span><\/p>\n<p><!--more-->&#8212;&#8212;\u4ee5\u4e0b\u70ba\u788e\u788e\u5538\u5c08\u5340\uff0c\u60f3\u770bcode \u76f4\u63a5\u62c9\u5230\u6700\u5e95&#8212;&#8212;&#8212;&#8212;<br \/>\n\u5c0doem\/odm\u5ee0\u4f86\u8aaa\uff0c\u5e38\u5e38\u807d\u5230\u7684\u9700\u6c42\u90fd\u662f<br \/>\npm:xxx\u6a5f\u5668\u5e0c\u671b\u4e0a\u9762\u7684launcher,\u684c\u9762 wallpaper\u662f\u7c89\u7d05\u8272\uff0c\u56e0\u70ba\u4e3b\u6253\u7684\u662f\u5973\u6027\u5e02\u5834\u5594<br \/>\nrd:\u5594\uff0c\u4e86\u89e3<br \/>\npm: \u4e2d\u570b\u5730\u5340\u4e0d\u80fd\u51fa\u73fegoogle app\u5594\uff0c\u8a18\u5f97\u95dc\u6389\u5594<br \/>\nrd:\u5594\uff0c\u4e86\u89e3<br \/>\npm: \u4e2d\u83ef\u96fb\u4fe1\u7684\u6a5f\u5b50\u4e00\u5b9a\u8981\u653ehami\u5728default workspace\u5594<br \/>\nrd:\u5594\uff0c\u4e86\u89e3<\/p>\n<p>\u786c\u8981\u8aaa\u8d77\u4f86\uff0c\u9019\u7a2e\u6771\u897f\u6539\u8d77\u4f86\u4e00\u9ede\u90fd\u4e0d\u96e3\uff0c\u4f46\u662f\u6bcf\u6b21\u90fd\u8981\u82b1\u6642\u9593\uff08\u91cd\u9ede\u662fcontext switch\uff09<br \/>\n\u800c\u4e14\u5982\u679c\u8981\u653e\u4e0a play store \u7684\u8a71\uff0c\u4e0a\u8ff0\u7684\u5c0d\u8a71\u6839\u672c&#8230;<\/p>\n<p>\u9019\u6642\u5019\uff0c\u4f60\u8001\u95c6\u770b\u5230\u5f88\u591alauncher \u90fd\u53ef\u4ee5\u653e\u4e0aplay store\u4e0a\uff0c\u60f3\u8aaa\u653e\u4e0a\u53bb\u53ef\u4ee5\u9806\u4fbf\u8cfa\u4e00\u4e0b<br \/>\n\u4e0b\u8f09\u9322<br \/>\n\u4f46\u662fpm\u7684\u8981\u6c42\u53ef\u80fd\u53c8\u6703\u6839\u64da\u8981\u51fa\u8ca8\u7684\u6a5f\u5b50\uff0c\u5343\u8b8a\u842c\u5316\uff0c\u653e\u5728play store\u4e0a\u53c8\u5f88\u96e3\u9054\u5230<br \/>\n<del datetime=\"2015-05-23T17:14:49+00:00\">\u52a0\u4e0a\u9019\u7fa4\u4eba\u5f88\u7169<\/del><br \/>\n\u9019\u6642\u4e7e\u8106\u628a\u9019\u7a2e\u8981\u6c42\u7d66\u5207\u51fa\u4f86\uff0c\u7136\u5f8c\u8b93\u5176\u4ed6\u7684team\u53bbhandle.\u53ef\u662f\u7e3d\u8981\u63d0\u51fa\u4e00\u500b\u65b9\u6848<br \/>\n\u8b93\u5b83\u9580\u53ef\u4ee5\u81ea\u52d5\u5316\u53bb\u641e\u5b9a<\/p>\n<p><strong>\u524d\u8a00\u72d7\u5c41\u90a3\u67d0\u591a\uff0c\u7d50\u8ad6\u5c31\u662f\u5148\u5728\u5404\u81ea\u7684\u6a5f\u7a2e\u4e2d\u5c07\u8981\u5ba2\u88fd\u5316\u7684\u90e8\u4efd\u5c08\u9580\u653e\u5230\u5c08\u9580\u7684app\u88e1<\/strong><br \/>\n<strong> \u4f8b\u5982 customize.apk\u4e4b\u985e\u7684\uff0c\u7136\u5f8c\u5728\u88e1\u9762\u5b9a\u7fa9\u597d\u683c\u5f0f\u653e\u5728resource\u88e1<\/strong><\/p>\n<p>\u800c\u9019\u4e9b\u503c\u53ef\u4ee5\u518dbuild system \u5c31\u5b9a\u7fa9\u597d\uff0c\u518d\u6a5f\u5b50\u51fa\u8ca8\u7684\u6642\u5019\u76f4\u63a5\u5305\u542b\u518d\u88e1\u9762\uff0c\u7136\u5f8c\u8b93<br \/>\nlauncher \u53bb\u6e96\u5099\u5b58\u53d6 \uff0c\u9019\u6a23\u5c31\u662f\u4e00\u500b\u7c21\u55ae\u7684d\/c\u5206\u96e2\u4e86\uff0c\u96d6\u7136\u4f60\u53ef\u80fd\u6703\u89ba\u7684\u53ea\u662f\u628a<br \/>\n\u4fee\u6539\u8cc7\u6599\u8f49\u79fb\u5230\u53e6\u5916\u4e00\u652f ap \u4e0a\u9762\uff0c\u5de5\u9084\u662f\u4e00\u6a23\uff0c\u4f46\u5176\u5be6\u9084\u662f\u6709\u5dee\u7570\u7684<\/p>\n<p><strong>1.\u81f3\u5c11\u628a\u4fee\u8a72\u7684\u8cc7\u6599\u5206\u96e2\u51fa\u4f86\uff0c\u4ee5\u4fbf\u65bc\u5176\u4ed6\u4eba\u9032\u884c\u4fee\u6539\uff0c\u4e0d\u6703\u4e0d\u5c0f\u5fc3\u6539\u58de\u4f60\u539f\u672c\u7684code<\/strong><br \/>\n<strong> (job fw to others is good)<\/strong><br \/>\n<strong> 2.\u53ef\u4ee5\u628acontrol\u7aef\u7684ap\u5206\u96e2\u51fa\u4f86\uff0c\u7136\u5f8c\u53ef\u4ee5\u4e1f\u4e0a play store.<\/strong><\/p>\n<p>\u4e0acode\u5566\uff1a<\/p>\n<pre>static boolean FEATURE_UI_CUSTOMIZE;\r\nContext context;\r\ntry {\r\n     context = createPackageContext(\"com.android.customize\", Context.CONTEXT_INCLUDE_CODE\r\n         | Context.CONTEXT_IGNORE_SECURITY);\r\n     FEATURE_UI_CUSTOMIZE = context.getResources().getBoolean(R.bool.feature_ui_customize);\r\n} catch (NameNotFoundException e) {\r\n     \/\/ If not found , you can assign default value here.\r\n     Feature_UI_CUSTOMIZE  = false;\r\n     e.printStackTrace();\r\n }\r\n\r\n<\/pre>\n<p>\u5176\u5be6\u4e5f\u53ef\u4ee5\u5229\u7528\u9019\u500b\u907f\u958b\u4e00\u4e9b sku \u554f\u984c<br \/>\n\u50cf\u662f\u518d\u5927\u9678\u5340 \u4e0d\u60f3\u51fa\u73fe\u516d\u56db\u5929\u5b89\u9580\uff0c\u90a3\u4e5f\u53ef\u4ee5\u9019\u6a23\u53bb\u53d6\u4ee3\u3002\uff08\u4ee5\u4e0a\u65bc2014\u5e74\u7684\u5fc3\u5f97\uff09<\/p>\n<p>\u96d6\u7136\u9019\u4e00\u5957\u62ff\u8cc7\u6599\u65b9\u6cd5\u4e0d\u932f\uff0c\u53ef\u662f\u518d5.0\u4e4b\u5f8c\u63a8\u51fa\u7684runtime overlay \u5b8c\u5168\u7c21\u5316\u4e00\u4e0a\u6b65\u9a5f<br \/>\n\u56e0\u6b64\u53ef\u80fd\u57285.0\u4e4b\u524d\u6bd4\u8f03\u5be6\u7528\uff0c\u4e4b\u5f8c\u518d\u51fa\u4e00\u7ae0\u7bc0\u8ac7 runtime overlay.<\/p>\n<p>ref:<br \/>\nhttp:\/\/blog.csdn.net\/darlk\/article\/details\/7742918<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u96bb\u5beb\u597d\u7684android app \u6700\u4f73\u60c5\u6cc1\u4e0b\uff0c\u4f60\u6703\u5e0c\u671b\u4e0d\u7ba1porting \u5230\u54ea\u4e00\u53f0\u6a5f\u5668\u90fd\u80fd\u5403\u904d\u5929\u4e0b\u7121\u6575\u624b \u9019\u807d\u8d77\u4f86\u5f88\u50cf\u5ee2\u8a71\uff0c\u4f46\u662f\u5176\u5be6\u641e\u8d77\u4f86\u4e0d\u662f\u96a8\u96a8\u4fbf\u4fbf\u7684 \u5149\u662f\u4e00\u822cthird app \u5c31\u8981\u6ce8\u610f\u5404\u7a2edpi&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[6,49],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/41"}],"collection":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":0,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}