{"id":1906,"date":"2022-11-25T18:00:42","date_gmt":"2022-11-25T10:00:42","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/1906.html"},"modified":"2022-11-25T18:00:42","modified_gmt":"2022-11-25T10:00:42","slug":"android-13-%e5%ba%94%e7%94%a8%e9%80%82%e9%85%8d%e6%8c%87%e5%8d%972%ef%bc%8c%e5%ae%89%e5%8d%9313%e6%96%b0%e5%8a%9f%e8%83%bd%e5%92%8capi","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/1906.html","title":{"rendered":"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI"},"content":{"rendered":"<h2 id=\"_1\">2.\u65b0\u529f\u80fd\u548cAPI<\/h2>\n<h3 id=\"_1_0\">2.1 \u7167\u7247\u9009\u62e9\u5668<\/h3>\n<p><span class=\"wpcom_tag_link\">Android 13<\/span> \u5305\u542b\u5bf9\u65b0\u7167\u7247\u9009\u62e9\u5668\u5de5\u5177\u7684\u652f\u6301\u3002\u6b64\u5de5\u5177\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u4e00\u79cd\u5b89\u5168\u7684\u5185\u7f6e\u5a92\u4f53\u6587\u4ef6\u9009\u62e9\u65b9\u5f0f\uff0c\u8ba9\u5176\u65e0\u9700\u5411\u5e94\u7528\u6388\u4e88\u5bf9\u6574\u4e2a\u5a92\u4f53\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002<strong>\u6ce8\u610f<\/strong><\/p>\n<p>\uff1a\u5373\u5c06\u53d1\u5e03\u7684 <span class=\"wpcom_tag_link\">Google Play<\/span> \u7cfb\u7edf\u66f4\u65b0\u9884\u8ba1\u4f1a\u5305\u542b\u4e0e\u7167\u7247\u9009\u62e9\u5668\u6709\u5173\u7684\u65b0\u529f\u80fd\u3002\u5728\u4e00\u9879\u6b64\u7c7b\u66f4\u65b0\u4e2d\uff0c\u8be5\u5e93\u5c06\u589e\u52a0\u5bf9\u4ee5 <span class=\"wpcom_tag_link\">Android 11<\/span>\uff08API \u7ea7\u522b 30\uff09\u6216\u66f4\u9ad8\u7248\u672c\u4e3a\u76ee\u6807\u5e73\u53f0\u7684\u5e94\u7528\uff08\u4e0d\u5305\u62ec <span class=\"wpcom_tag_link\">Android Go<\/span> \u8bbe\u5907\uff09\u7684\u652f\u6301\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152536948.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152536948.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<h4>2.1.1 \u9009\u62e9\u5a92\u4f53<\/h4>\n<p>\u7167\u7247\u9009\u62e9\u5668\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53ef\u6d4f\u89c8\u3001\u53ef\u641c\u7d22\u7684\u754c\u9762\uff0c\u5176\u4e2d\u6309\u65e5\u671f\uff08\u4ece\u6700\u8fd1\u5230\u6700\u65e9\uff09\u987a\u5e8f\u5411\u7528\u6237\u5448\u73b0\u5176\u5a92\u4f53\u5e93\u4e2d\u7684\u6587\u4ef6\u3002\u60a8\u53ef\u4ee5\u6307\u5b9a\u7528\u6237\u53ea\u80fd\u770b\u5230\u7167\u7247\u6216\u53ea\u80fd\u770b\u5230\u89c6\u9891\uff0c\u5e76\u4e14\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5141\u8bb8\u7684\u5a92\u4f53\u9009\u62e9\u91cf\u4e0a\u9650\u8bbe\u7f6e\u4e3a 1\u3002<\/p>\n<h4>2.1.2 \u5b9a\u4e49\u5206\u4eab\u9650\u5236<\/h4>\n<p>\u5e94\u7528\u53ef\u4ee5\u58f0\u660eandroid.provider.extra.PICK_IMAGES_MAX\u7684\u503c\uff0c\u8be5\u503c\u8868\u793a\u5728\u5411\u7528\u6237\u663e\u793a\u65f6\u7167\u7247\u9009\u62e9\u5668\u4e2d\u663e\u793a\u7684\u5a92\u4f53\u6587\u4ef6\u6570\u91cf\u4e0a\u9650\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u63d0\u793a\u7528\u6237\u4e3a\u5176\u5e10\u53f7\u9009\u62e9\u8981\u6c42\u7684\u4e2a\u4eba\u8d44\u6599\u7167\u7247\uff0c\u8bf7\u5c06<strong>\u4e00\u5f20\u7167\u7247<\/strong>\u8bbe\u7f6e\u4e3a\u5206\u4eab\u8981\u6c42\u4e0a\u9650\u3002<strong>\u6ce8\u610f<\/strong><\/p>\n<p>\uff1a\u5982\u679c\u60a8\u9009\u62e9\u7684\u4e0a\u9650\u4e3a 1 \u5f20\uff0c\u7167\u7247\u9009\u62e9\u5668\u4f1a\u4ee5\u534a\u5c4f\u6a21\u5f0f\u6253\u5f00\u3002<\/p>\n<p>\u5982\u9700\u5728\u5355\u9009\u6a21\u5f0f\u4e0b\u542f\u52a8\u7167\u7247\u9009\u62e9\u5668\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ Lau<a href=\"https:\/\/app.applebyme.cn\/shengcheng-40.html\">\u7f51\u7ad9\u5c01\u88c5ipa<\/a>nches photo picker in single-select mode.\n\/\/ This means that the user can select one photo or video.\nIntent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);\nstartActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE);\n<\/code><\/pre>\n<h4>2.1.3 \u9009\u62e9\u591a\u5f20\u7167\u7247\u6216\u591a\u4e2a\u89c6\u9891<\/h4>\n<p>\u5982\u679c\u5e94\u7528\u7684\u7528\u4f8b\u9700\u8981\u7528\u6237\u9009\u62e9\u591a\u5f20\u7167\u7247\u6216\u591a\u4e2a\u89c6\u9891\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528EXTRA_PICK_IMAGES_MAX&nbsp;extra \u6307\u5b9a\u7167\u7247\u9009\u62e9\u5668\u4e2d\u5e94\u663e\u793a\u7167\u7247\u7684\u6570\u91cf\u4e0a\u9650\uff0c\u5982\u4ee5\u4e0b\u4ee3\u7801\u6bb5\u4e2d\u6240\u793a\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ Launches photo picker in multi-select mode.\n\/\/ This means that user can select multiple photos\/videos, up to the limit\n\/\/ specified by the app in the extra (10 in this example).\nfinal int maxNumPhotosAndVideos = 10;\nIntent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);\nintent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, maxNumPhotosAndVideos);\nstartActivityForResult(intent, PHOTO_PICKER_MULTI_SELECT_REQUEST_CODE);\n<\/code><\/pre>\n<p>\u8bf7\u6ce8\u610f\uff0c\u53ef\u6307\u5b9a\u4e3a\u6587\u4ef6\u6570\u91cf\u4e0a\u9650\u7684\u6700\u5927\u6570\u5b57\u5b58\u5728\u5e73\u53f0\u9650\u5236\u3002\u5982\u9700\u8bbf\u95ee\u6b64\u9650\u5236\uff0c\u8bf7\u8c03\u7528MediaStore#getPickImagesMaxLimit()\u3002<\/p>\n<h4>2.1.4 \u5904\u7406\u7167\u7247\u9009\u62e9\u5668\u7ed3\u679c<\/h4>\n<p>\u7167\u7247\u9009\u62e9\u5668\u542f\u52a8\u540e\uff0c\u4f7f\u7528\u65b0\u7684ACTION_PICK_IMAGES&nbsp;intent \u6765\u5904\u7406\u7ed3\u679c\u3002\u8be5\u9009\u62e9\u5668\u4f1a\u8fd4\u56de\u4e00\u7ec4 URI\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ onActivityResult() handles callbacks from the photo picker.\n@Override\nprotected void onActivityResult(\n    int requestCode, int resultCode, final Intent data) {\n    if (resultCode != Activity.RESULT_OK) {\n        \/\/ Handle error\n        return;\n    }\n    switch(requestCode) {\n        case REQUEST_PHOTO_PICKER_SINGLE_SELECT:\n            \/\/ Get photo picker response for single select.\n            Uri currentUri = data.getData();\n            \/\/ Do stuff with the photo\/video URI.\n            return;\n        case REQUEST_PHOTO_PICKER_MULTI_SELECT:\n            \/\/ Get photo picker response for multi select\n            for (int i = 0; i &lt; data.getClipData().getItemCount(); i++) {\n                Uri currentUri = data.getClipData().getItemAt(i).getUri();\n                \/\/ Do stuff with each photo\/video URI.\n            }\n            return;\n    }\n}\n<\/code><\/pre>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7167\u7247\u9009\u62e9\u5668\u4f1a\u65e2\u663e\u793a\u7167\u7247\u53c8\u663e\u793a\u89c6\u9891\u3002\u60a8\u8fd8\u53ef\u4ee5\u5728 setType() \u65b9\u6cd5\u4e2d\u8bbe\u7f6e MIME \u7c7b\u578b\uff0c\u4ee5\u4fbf\u6309\u201c\u4ec5\u663e\u793a\u7167\u7247\u201d\u6216\u201c\u4ec5\u663e\u793a\u89c6\u9891\u201d\u8fdb\u884c\u8fc7\u6ee4\u3002\u4f8b\u5982\uff0c\u5982\u9700\u5728\u7167\u7247\u9009\u62e9\u5668\u4e2d\u4ec5\u663e\u793a\u89c6\u9891\uff0c\u8bf7\u5c06video\/*\u4f20\u5165setType()\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ Launches photo picker for videos only in single select mode.\nIntent intent = new Intent(MediaStore.ACTION_PICK_IMAGES);\nintent.setType(\"video\/*\");\nstartActivityForResult(intent, );\n\/\/ Apps can also change the mimeType to allow users to select\n\/\/ images only - intent.setType(\"images\/*\");\n\/\/ or a specific mimeType - intent.setType(\"image\/gif\");\n<\/code><\/pre>\n<p>\u6ce8\u610f\uff1a\u60a8\u7684\u5e94\u7528\u4e0d\u80fd\u6301\u7eed\u8bbf\u95ee\u4ece\u6b64 intent \u8fd4\u56de\u7684 URI\u3002\u5f53\u5e94\u7528\u7684\u8fdb\u7a0b\u7ed3\u675f\u540e\uff0c\u8be5\u5e94\u7528\u5c06\u65e0\u6cd5\u8bbf\u95ee URI\u3002<\/p>\n<h3 id=\"_1_1\">2.2 \u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668<\/h3>\n<p>\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\uff0c\u591a\u8bed\u8a00\u7528\u6237\u4f1a\u5c06\u5176\u7cfb\u7edf\u8bed\u8a00\u8bbe\u7f6e\u4e3a\u67d0\u4e00\u79cd\u8bed\u8a00\uff08\u4f8b\u5982\u82f1\u8bed\uff09\uff0c\u4f46\u53c8\u60f3\u4e3a\u7279\u5b9a\u5e94\u7528\u9009\u62e9\u5176\u4ed6\u8bed\u8a00\uff08\u4f8b\u5982\u8377\u5170\u8bed\u3001\u4e2d\u6587\u6216\u5370\u5730\u8bed\uff09\u3002\u4e3a\u4e86\u5e2e\u52a9\u5e94\u7528\u4e3a\u8fd9\u4e9b\u7528\u6237\u63d0\u4f9b\u66f4\u597d\u7684\u4f53\u9a8c\uff0cAndroid 13 \u9488\u5bf9\u652f\u6301\u591a\u79cd\u8bed\u8a00\u7684\u5e94\u7528\u5f15\u5165\u4e86\u4ee5\u4e0b\u65b0\u529f\u80fd\uff1a<\/p>\n<ul>\n<li>\u4f7f\u5e94\u7528\u53ef\u5728\u8fd0\u884c\u65f6\u8bbe\u7f6e\u5728\u754c\u9762\u4e2d\u4f7f\u7528\u5176\u4ed6\u8bed\u8a00\u7684 API<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u81ea\u5b9a\u4e49\u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668\u7684\u5e94\u7528\u5e94\u5f53\u4f7f\u7528\u8fd9\u4e9b\u65b0 API\uff0c\u4ee5\u786e\u4fdd\u65e0\u8bba\u7528\u6237\u901a\u8fc7\u4f55\u79cd\u65b9\u5f0f\u9009\u62e9\u5176\u8bed\u8a00\u504f\u597d\u8bbe\u7f6e\uff0c\u90fd\u80fd\u83b7\u5f97\u4e00\u81f4\u7684\u7528\u6237\u4f53\u9a8c\u3002\u8fd9\u4e9b\u65b0\u7684 API \u8fd8\u6709\u52a9\u4e8e\u51cf\u5c11\u6837\u677f\u4ee3\u7801\u7684\u7f16\u5199\u3002<\/p>\n<p>\u4e3a\u4e86\u5411\u540e\u517c\u5bb9\u4ee5\u524d\u7684 Android \u7248\u672c\uff0c\u6211\u4eec\u8fd8\u4f1a\u4eceAppcompat 1.6.0-alpha01\u5f00\u59cb\u5728 AndroidX \u4e2d\u63d0\u4f9b\u8fd9\u4e9b API\u3002<\/p>\n<ul>\n<li>\u5141\u8bb8\u7528\u6237\u4e3a\u6bcf\u4e2a\u5e94\u7528\u9009\u62e9\u9996\u9009\u8bed\u8a00\u7684\u7cfb\u7edf\u8bbe\u7f6e<\/li>\n<\/ul>\n<p>\u4e0d\u652f\u6301\u591a\u79cd\u8bed\u8a00\u7684\u5e94\u7528\u4e0d\u53d7\u8fd9\u4e9b\u53d8\u66f4\u7684\u5f71\u54cd\u3002<\/p>\n<h4>2.2.1 API \u5b9e\u73b0<\/h4>\n<p>\u5bf9\u4e8e\u5f53\u524d\u672a\u4f7f\u7528\u81ea\u5b9a\u4e49\u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668\u7684\u5e94\u7528\uff0c\u65e0\u9700\u6267\u884c\u4efb\u4f55\u5176\u4ed6\u64cd\u4f5c\u3002<\/p>\n<p>\u5bf9\u4e8e\u5177\u6709\u6216\u60f3\u8981\u4f7f\u7528\u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668\u7684\u5e94\u7528\uff0c\u8bf7\u4f7f\u7528\u8fd9\u4e9b\u65b0 API\uff08\u800c\u975e\u5e94\u7528\u7684\u81ea\u5b9a\u4e49\u903b\u8f91\uff09\u6765\u5904\u7406\u76f8\u5173\u8bbe\u7f6e\u548c\u83b7\u53d6\u7528\u6237\u5bf9\u5e94\u7528\u7684\u9996\u9009\u8bed\u8a00\u8bbe\u7f6e\u3002<\/p>\n<h4>\u4f7f\u7528 AndroidX \u652f\u6301\u5e93\u6765\u5b9e\u73b0<\/h4>\n<p>\u4e3a\u4e86\u5411\u540e\u517c\u5bb9\u4ee5\u524d\u7684 Android \u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528 AndroidX \u652f\u6301\u5e93\u6765\u5b9e\u73b0\u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668\u3002\u4f7f\u7528Appcompat 1.6.0-alpha01\u6216\u66f4\u9ad8\u7248\u672c\u4e2d\u63d0\u4f9b\u7684setApplicationLocales()\u65b9\u6cd5\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u9700\u8bbe\u7f6e\u7528\u6237\u7684\u9996\u9009\u8bed\u8a00\uff0c\u60a8\u9700\u8981\u8ba9\u7528\u6237\u5728\u8bed\u8a00\u9009\u62e9\u5668\u4e2d\u9009\u62e9\u8bed\u8a00\u533a\u57df\uff0c\u7136\u540e\u5728\u7cfb\u7edf\u4e2d\u8bbe\u7f6e\u8be5\u503c\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>LocaleListCompat appLocale = LocaleListCompat.forLanguageTags(\"xx-YY\");\n\/\/ Call this on the main thread as it may require Activity.restart()\nAppCompatDelegate.setApplicationLocales(appLocale);\n<\/code><\/pre>\n<h4>\u4f7f\u7528 Android \u6846\u67b6 API \u6765\u5b9e\u73b0<\/h4>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7setApplicationLocales()\u548cgetApplicationLocales()\u65b9\u6cd5\uff0c\u4f7f\u7528 Android \u6846\u67b6 API \u6765\u5b9e\u73b0\u5e94\u7528\u5185\u8bed\u8a00\u9009\u62e9\u5668\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u9700\u8bbe\u7f6e\u7528\u6237\u7684\u9996\u9009\u8bed\u8a00\uff0c\u60a8\u9700\u8981\u8ba9\u7528\u6237\u5728\u8bed\u8a00\u9009\u62e9\u5668\u4e2d\u9009\u62e9\u8bed\u8a00\u533a\u57df\uff0c\u7136\u540e\u5728\u7cfb\u7edf\u4e2d\u8bbe\u7f6e\u8be5\u503c\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ 1. Inside an activity, in-app language picker gets an input locale \"xx-YY\"\n\/\/ 2. App calls the API to set its localem\nContext.getSystemService(LocaleManager.class).setApplicationLocales(newLocaleList(Locale.forLanguageTag(\"xx-YY\")));\n\/\/ 3. The system updates the locale and restarts the app, including any configuration updates\n\/\/ 4. The app is now displayed in \"xx-YY\" language\n<\/code><\/pre>\n<p>\u5982\u9700\u83b7\u53d6\u7528\u6237\u5f53\u524d\u7684\u9996\u9009\u8bed\u8a00\u4ee5\u663e\u793a\u5728\u8bed\u8a00\u9009\u62e9\u5668\u4e2d\uff0c\u60a8\u7684\u5e94\u7528\u53ef\u4ee5\u4ece\u7cfb\u7edf\u4e2d\u53d6\u56de\u8be5\u503c\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ 1. App calls the API to get the preferred locale\nLocaleList currentAppLocales = mContext.getSystemService(LocaleManager.class).getApplicationLocales();\n\/\/ 2. App uses the returned LocaleList to display languages to the user\n<\/code><\/pre>\n<h4>2.2.2 \u9762\u5411\u7528\u6237\u7684\u7cfb\u7edf\u8bbe\u7f6e<\/h4>\n<p>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u65b0\u7684\u7cfb\u7edf\u8bbe\u7f6e\u4e3a\u6bcf\u4e2a\u5e94\u7528\u9009\u62e9\u9996\u9009\u8bed\u8a00\u3002\u4ed6\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8bbf\u95ee\u8fd9\u4e9b\u8bbe\u7f6e\uff1a<\/p>\n<ul>\n<li>\u901a\u8fc7\u7cfb\u7edf\u8bbe\u7f6e\u8bbf\u95ee<\/li>\n<\/ul>\n<p><strong>\u8bbe\u7f6e &gt; \u7cfb\u7edf &gt; \u8bed\u8a00\u548c\u8f93\u5165\u6cd5 &gt; \u5e94\u7528\u8bed\u8a00 &gt;\uff08\u9009\u62e9\u5e94\u7528\uff09<\/strong><\/p>\n<ul>\n<li>\u901a\u8fc7\u5e94\u7528\u8bbe\u7f6e\u8bbf\u95ee<\/li>\n<\/ul>\n<p><strong>\u8bbe\u7f6e &gt; \u5e94\u7528 &gt;\uff08\u9009\u62e9\u4e00\u6b3e\u5e94\u7528\uff09&gt; \u8bed\u8a00<\/strong><\/p>\n<h4>\u5df2\u77e5\u95ee\u9898<\/h4>\n<p>\u5728\u6d4b\u8bd5\u5e94\u7528\u65f6\uff0c\u6709\u4e00\u4e9b\u5df2\u77e5\u95ee\u9898\u9700\u8981\u6ce8\u610f\u3002<\/p>\n<ul>\n<li>\u53ef\u7528\u8bed\u8a00\u5217\u8868\u4e2d\u53ef\u80fd\u4e0d\u5305\u542b\u60a8\u7684\u5e94\u7528\u652f\u6301\u7684\u8bed\u8a00\u3002<\/li>\n<li>\u5982\u679c\u60a8\u7684\u5e94\u7528\u4f7f\u7528\u62c6\u5206 APK\uff0c\u5f53\u5e94\u7528\u8bed\u8a00\u533a\u57df\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u7cfb\u7edf\u4e0d\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u8fd9\u4e9b APK\u3002<\/li>\n<li>\u73b0\u5728\u7684\u754c\u9762\u53ea\u662f\u4e00\u4e2a\u521d\u6b65\u7248\u672c\uff0c\u5728\u540e\u7eed\u7248\u672c\u4e2d\u4f1a\u4e0d\u65ad\u66f4\u6539\u3002<\/li>\n<\/ul>\n<h4>2.2.3 DEMO\u6f14\u793a<\/h4>\n<h3 id=\"_1_2\"><\/h3>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152558657.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152558657.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<h3 id=\"_1_3\">2.3 \u53ef\u7531\u5f00\u53d1\u8005\u964d\u7ea7\u7684\u6743\u9650<\/h3>\n<p>\u4ece Android 13 \u5f00\u59cb\uff0c\u5e94\u7528\u53ef\u4ee5\u64a4\u6d88\u5148\u524d\u7531\u7cfb\u7edf\u6216\u7528\u6237\u6388\u4e88\u7684\u8fd0\u884c\u65f6\u6743\u9650\u3002\u6b64 API \u53ef\u4ee5\u5e2e\u52a9\u5e94\u7528\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u3002<\/p>\n<p>\u5982\u9700\u64a4\u6d88\u7279\u5b9a\u8fd0\u884c\u65f6\u6743\u9650\uff0c\u8bf7\u5c06\u8be5\u6743\u9650\u7684\u540d\u79f0\u4f20\u5165revokeSelfPermissionOnKill()\u3002\u5982\u9700\u540c\u65f6\u64a4\u6d88\u4e00\u7ec4\u8fd0\u884c\u65f6\u6743\u9650\uff0c\u8bf7\u5c06\u8fd9\u7ec4\u6743\u9650\u7684\u540d\u79f0\u4f20\u5165revokeSelfPermissionsOnKill()\u3002\u64a4\u6d88\u662f\u5f02\u6b65\u53d1\u751f\u7684\uff0c\u4f1a\u7ec8\u6b62\u4e0e\u5e94\u7528\u7684 UID \u76f8\u5173\u8054\u7684\u6240\u6709\u8fdb\u7a0b\u3002<\/p>\n<p>\u7cfb\u7edf\u53ea\u6709\u5728\u5b89\u5168\u7684\u60c5\u51b5\u4e0b\u624d\u4f1a\u89e6\u53d1\u64a4\u6d88\u64cd\u4f5c\u3002\u5177\u4f53\u800c\u8a00\uff0c\u5f53\u6709\u5e94\u7528\u7ec4\u4ef6\u4ecd\u5728\u524d\u53f0\u8fd0\u884c\uff0c\u6216\u8005\u6709\u53e6\u4e00\u4e2a\u5e94\u7528\u6b63\u5728\u8bbf\u95ee\u60a8\u5e94\u7528\u7684\u7ec4\u4ef6\uff08\u5982 content provider\uff09\u65f6\uff0c\u4e0d\u4f1a\u53d1\u751f\u64a4\u6d88\u3002\u5982\u679c\u60a8\u60f3\u7acb\u5373\u64a4\u6d88\u6743\u9650\uff0c\u53ef\u4ee5\u8c03\u7528exit()\u3002\u4f46\u662f\uff0c\u5bf9exit()\u8fdb\u884c\u6b64\u7c7b\u8c03\u7528\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5f53\u524d\u6b63\u5728\u8bbf\u95ee\u60a8\u5e94\u7528\u7684\u5176\u4ed6\u5e94\u7528\u51fa\u73b0\u672a\u5b9a\u4e49\u7684\u884c\u4e3a\u6216\u5d29\u6e83\u3002\u6ce8\u610f<\/p>\n<p>\uff1a\u4e3a\u4e86\u8ba9\u7cfb\u7edf\u8bbe\u7f6e\u8868\u660e\u60a8\u7684\u5e94\u7528\u4e0d\u4f1a\u8bbf\u95ee\u7279\u5b9a\u6743\u9650\u7ec4\u4e2d\u7684\u6570\u636e\uff0c\u60a8\u5fc5\u987b\u64a4\u6d88\u8be5\u6743\u9650\u7ec4\u4e2d\u7684<strong>\u6240\u6709<\/strong><\/p>\n<p>\u6743\u9650\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8c03\u7528<code>revokeSelfPermissionsOnKill()<\/code><\/p>\n<p>\u4f1a\u5f88\u6709\u5e2e\u52a9\u3002<\/p>\n<h3 id=\"_1_4\">2.4 \u53ef\u7f16\u7a0b\u7684\u7740\u8272\u5668<\/h3>\n<p>Android 13 \u6dfb\u52a0\u4e86\u5bf9\u53ef\u7f16\u7a0bRuntimeShader\u5bf9\u8c61\u7684\u652f\u6301\uff0c\u5176\u884c\u4e3a\u662f\u4f7f\u7528 Android \u56fe\u5f62\u7740\u8272\u8bed\u8a00 (AGSL) \u5b9a\u4e49\u7684\u3002AGSL \u4e0e GLSL \u5171\u7528\u5927\u90e8\u5206\u8bed\u6cd5\uff0c\u4f46\u53ef\u7528\u4e8e Android \u6e32\u67d3\u5f15\u64ce\u4e2d\u4ee5\u81ea\u5b9a\u4e49 Android \u753b\u5e03\u4e2d\u7684\u7ed8\u5236\u884c\u4e3a\u4ee5\u53ca\u8fc7\u6ee4 View \u5185\u5bb9\u3002Android \u5728\u5185\u90e8\u4f7f\u7528\u8fd9\u4e9b\u7740\u8272\u5668\u6765\u5b9e\u73b0\u6d9f\u6f2a\u6548\u679c\u3001\u6a21\u7cca\u4ee5\u53ca\u62c9\u4f38\u6eda\u52a8\uff0c\u5e76\u4e14 Android 13 \u8ba9\u60a8\u80fd\u4e3a\u5e94\u7528\u5236\u4f5c\u7c7b\u4f3c\u7684\u9ad8\u7ea7\u6548\u679c\u3002\u6539\u5199\u81ea\u6b64GLSL \u7740\u8272\u5668\u7684 AGSL \u52a8\u753b\u7740\u8272\u5668\uff1a<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152601507.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152601507.gif\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<p>\u57fa\u4e8e\u53ef\u7f16\u7a0b\u7740\u8272\u5668\u5b9e\u73b0\u7684\u4e00\u4e2a\u7b80\u5355\u7684\u7ed8\u5236\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152621602.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152621602.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<h3 id=\"_1_5\">2.5 \u66f4\u5feb\u65ad\u5b57<\/h3>\n<p>\u65ad\u5b57\u8ba9\u5206\u884c\u7684\u6587\u672c\u66f4\u6613\u4e8e\u9605\u8bfb\uff0c\u5e76\u4e14\u6709\u52a9\u4e8e\u4f7f\u754c\u9762\u66f4\u5177\u81ea\u9002\u5e94\u6027\u3002\u5728 Android 13 \u4e2d\uff0c\u6211\u4eec\u5c06\u65ad\u5b57\u6027\u80fd\u4f18\u5316\u4e86\u591a\u8fbe 200%\uff0c\u56e0\u6b64\u60a8\u73b0\u5728\u53ef\u4ee5\u5728TextView\u4e2d\u542f\u7528\u65ad\u5b57\u529f\u80fd\uff0c\u8fd9\u51e0\u4e4e\u4e0d\u5f71\u54cd\u6e32\u67d3\u6027\u80fd\u3002\u5982\u9700\u542f\u7528\u66f4\u5feb\u65ad\u5b57\u529f\u80fd\uff0c\u8bf7\u5728setHyphenationFrequency()\u4e2d\u4f7f\u7528\u65b0\u7684fullFast\u6216normalFast\u9891\u7387\u3002<\/p>\n<h4>2.5.1 API\u53d8\u5316<\/h4>\n<p>Android 13\u5728\u5df2\u6709\u65ad\u5b57\u6a21\u5f0f\u57fa\u7840\u4e0a\u65b0\u589e\u4e24\u79cdFast\u6a21\u5f0f\uff1afullFast\u548cnormalFast\uff0c\u5728\u539f\u6709\u57fa\u7840\u4e0a\u6d4b\u91cf\u66f4\u5feb\u3002<\/p>\n<h4>2.5.2 \u4f7f\u7528\u5efa\u8bae<\/h4>\n<p>\u5728\u5e03\u5c40\u4e2d\u6dfb\u52a0\u5c5e\u6027android:hyphenationFrequency\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>&lt;!--\u5c11\u91cf\u5feb\u901f\u65ad\u5b57\u6a21\u5f0f--&gt;\n&lt;TextView android:hyphenationFrequency=\"fullFast\"\/&gt;\n&lt;!--\u6807\u51c6\u5feb\u901f\u65ad\u5b57\u6a21\u5f0f--&gt;\n&lt;TextView android:hyphenationFrequency=\"normalFast\"\/&gt;\n<\/code><\/pre>\n<p>\u4ee3\u7801\u4e2d\u76f4\u63a5\u8bbe\u7f6e\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>\/\/\u6807\u51c6\u5feb\u901f\u65ad\u5b57\u6a21\u5f0f\nmTextView.setHyphenationFrequency(Layout.<em>HYPHENATION_FREQUENCY_NORMAL_FAST<\/em>)\n\/\/\u5c11\u91cf\u5feb\u901f\u65ad\u5b57\u6a21\u5f0f\nmTextView.setHyphenationFrequency(Layout.<em>HYPHENATION_FREQUENCY_FULL_FAST<\/em>)<\/code><\/pre>\n<h1><\/h1>\n<h2 id=\"_2\">3.\u5f71\u54cd\u5e94\u7528\u7684\u884c\u4e3a\u53d8\u66f4<\/h2>\n<h3 id=\"_2_0\">3.1 \u884c\u4e3a\u53d8\u66f4\uff1a\u6240\u6709\u5e94\u7528<\/h3>\n<h4>3.1.1 \u524d\u53f0\u670d\u52a1 (FGS) \u4efb\u52a1\u7ba1\u7406\u5668<\/h4>\n<p>\u65e0\u8bba\u5e94\u7528\u91c7\u7528\u4f55\u79cd\u76ee\u6807 SDK \u7248\u672c\uff0cAndroid 13 \u90fd\u5141\u8bb8\u7528\u6237\u4ece\u62bd\u5c49\u5f0f\u901a\u77e5\u680f\u4e2d\u505c\u6b62\u524d\u53f0\u670d\u52a1\u3002\u8fd9\u9879\u65b0\u529f\u80fd\u79f0\u4e3a\u524d\u53f0\u670d\u52a1 (FGS) \u4efb\u52a1\u7ba1\u7406\u5668\uff0c\u5b83\u4f1a\u663e\u793a\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u524d\u53f0\u670d\u52a1\u7684\u5e94\u7528\u5217\u8868\u3002\u6b64\u5217\u8868\u7684\u6807\u7b7e\u4e3a<strong>\u4f7f\u7528\u4e2d\u7684\u5e94\u7528<\/strong>\u3002\u6bcf\u4e2a\u5e94\u7528\u65c1\u8fb9\u90fd\u6709\u4e00\u4e2a<strong>\u505c\u6b62<\/strong>\u6309\u94ae\u3002<\/p>\n<p>\u4e0b\u56fe\u8bf4\u660e\u4e86\u642d\u8f7d Android 13 \u7684\u8bbe\u5907\u4e0a\u7684 FGS \u4efb\u52a1\u7ba1\u7406\u5668\u7684\u5de5\u4f5c\u6d41\u7a0b\uff1a<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152624611.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152624611.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<h5>3.1.1.1 \u7528\u6237\u64cd\u4f5c\u4f1a\u505c\u6b62\u60a8\u7684\u6574\u4e2a\u5e94\u7528<\/h5>\n<p>\u5f53\u7528\u6237\u5728 FGS \u4efb\u52a1\u7ba1\u7406\u5668\u4e2d\u6309\u60a8\u5e94\u7528\u65c1\u8fb9\u7684<strong>\u505c\u6b62<\/strong>\u6309\u94ae\u65f6\uff0c\u7cfb\u7edf\u4f1a<strong>\u505c\u6b62\u60a8\u7684\u6574\u4e2a\u5e94\u7528<\/strong>\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u6b63\u5728\u8fd0\u884c\u7684\u524d\u53f0\u670d\u52a1\u3002<\/p>\n<p>\u6bd4\u8f83<a href=\"https:\/\/app.applebyme.cn\/shengcheng-83.html\">\u53ef\u4ee5\u751f\u6210app\u7684\u7f51\u9875<\/a>\u201c\u5411\u4e0a\u6ed1\u52a8\u201d\u7528\u6237\u64cd\u4f5c\u548c\u201c\u5f3a\u884c\u505c\u6b62\u201d\u7528\u6237\u64cd\u4f5c\u7684\u884c\u4e3a\uff1a<\/p>\n<p>\u8bf7\u53c2\u89c1\u4e0b\u8868\u4e2d FGS \u4efb\u52a1\u7ba1\u7406\u5668\u4e0e\u73b0\u6709\u529f\u80fd\u7684\u6bd4\u8f83\uff1a\u4ece<strong>\u6700\u8fd1\u7528\u8fc7<\/strong>\u5c4f\u5e55\u201c\u5411\u4e0a\u6ed1\u52a8\u201d\u548c\u201c\u5f3a\u884c\u505c\u6b62\u201d\u51fa\u73b0\u5f02\u5e38\u7684\u5e94\u7528\u3002<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152625157.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221124152625157.png\" alt=\"Android 13 \u5e94\u7528\u9002\u914d\u6307\u53572\uff0c\u5b89\u535313\u65b0\u529f\u80fd\u548cAPI\" \/><\/figure>\n<p>\u7528\u6237\u4ece FGS \u4efb\u52a1\u7ba1\u7406\u5668\u505c\u6b62\u5e94\u7528\u65f6\uff0c\u4e0d\u4f1a\u53d1\u9001\u4efb\u4f55\u56de\u8c03\u3002<\/p>\n<p>\u5f53\u7528\u6237\u6309<strong>\u505c\u6b62<\/strong>\u6309\u94ae\u65f6\uff0c\u7cfb\u7edf\u4e0d\u4f1a\u5411\u60a8\u7684\u5e94\u7528\u53d1\u9001\u4efb\u4f55\u56de\u8c03\u3002\u5f53\u5e94\u7528\u542f\u52a8\u5907\u4efd\u65f6\uff0c\u5efa\u8bae\u60a8\u68c0\u67e5\u4e00\u4e0b\u73b0\u6709ApplicationExitInfoAPI \u4e2d\u7684\u65b0REASON_USER_REQUESTED\u539f\u56e0\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f88\u6709\u5e2e\u52a9\u3002<\/p>\n<h5>3.1.1.2 \u4e0e\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u524d\u53f0\u670d\u52a1\u76f8\u5173\u7684\u7cfb\u7edf\u63d0\u793a<\/h5>\n<p>\u5982\u679c\u7cfb\u7edf\u68c0\u6d4b\u5230\u60a8\u7684\u5e94\u7528\u957f\u65f6\u95f4\u8fd0\u884c\u67d0\u9879\u524d\u53f0\u670d\u52a1\uff08\u5728 24 \u5c0f\u65f6\u7684\u65f6\u95f4\u6bb5\u5185\u81f3\u5c11\u8fd0\u884c 20 \u5c0f\u65f6\uff09\uff0c\u4fbf\u4f1a\u53d1\u9001\u901a\u77e5\u9080\u8bf7\u7528\u6237\u4e0e FGS \u4efb\u52a1\u7ba1\u7406\u5668\u4e92\u52a8\u3002\u8be6\u7ec6\u4e86\u89e3\u5c31\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u524d\u53f0\u670d\u52a1\u63d0\u9192\u7528\u6237\u7684\u65b0\u7cfb\u7edf\u901a\u77e5\u3002<\/p>\n<p>\u7f16\u8f91\uff1ayimen\uff0c\u5982\u82e5\u8f6c\u8f7d\uff0c\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttps:\/\/www.yimenapp.com\/kb-yimen\/12700\/<\/p>\n<p>\u90e8\u5206\u5185\u5bb9\u6765\u81ea\u7f51\u7edc\u6295\u7a3f\uff0c\u5982\u6709\u4fb5\u6743\u8054\u7cfb\u7acb\u5220<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2.\u65b0\u529f\u80fd\u548cAPI2.1 \u7167\u7247\u9009\u62e9\u5668Android 13 \u5305\u542b\u5bf9\u65b0\u7167\u7247\u9009\u62e9\u5668\u5de5\u5177\u7684\u652f\u6301\u3002\u6b64\u5de5\u5177\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u4e00\u79cd\u5b89\u5168\u7684\u5185\u7f6e\u5a92\u4f53\u6587\u4ef6\u9009\u62e9\u65b9\u5f0f\uff0c\u8ba9\u5176\u65e0\u9700\u5411\u5e94\u7528\u6388\u4e88\u5bf9\u6574\u4e2a\u5a92\u4f53\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002\u6ce8\u610f\uff1a\u5373\u5c06\u53d1\u5e03\u7684 Google Play \u7cfb\u7edf\u66f4\u65b0\u9884\u8ba1\u4f1a\u5305\u542b\u4e0e\u7167\u7247\u9009\u62e9\u5668\u6709\u5173\u7684\u65b0\u529f\u80fd\u3002\u5728\u4e00\u9879\u6b64\u7c7b\u66f4\u65b0\u4e2d\uff0c\u8be5\u5e93\u5c06\u589e\u52a0\u5bf9\u4ee5 <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[113,1125,1162],"class_list":["post-1906","post","type-post","status-publish","format-standard","hentry","category-appshangjia","tag-api","tag-1125","tag-1162"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=1906"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1906\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=1906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=1906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=1906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}