{"id":180,"date":"2016-09-14T08:00:41","date_gmt":"2016-09-14T08:00:41","guid":{"rendered":"https:\/\/boochlin.com\/?p=180"},"modified":"2026-09-19T18:04:14","modified_gmt":"2026-09-19T18:04:14","slug":"android-nougat-introduction-%e4%b8%80","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=180","title":{"rendered":"Android Nougat introduction (\u4e00)"},"content":{"rendered":"<blockquote>\n<p><strong>\u3010Android 7.0 Nougat (API 24)\u3011<\/strong> \u7cfb\u7d71\u5e95\u5c64\u67b6\u69cb\u3001\u591a\u91cd\u8996\u7a97\u3001JIT\/AOT \u7de8\u8b6f\u8207\u7db2\u8def\u5b89\u5168\u6df1\u5ea6\u5256\u6790<\/p>\n<\/blockquote>\n<p>\u96d6\u7136 Android N Preview \u5f9e Google I\/O \u4e94\u6708\u5927\u6703\u5c31\u91cb\u653e\u51fa\u4f86\uff0c\u4f46\u662f\u4e00\u76f4\u627e\u4e0d\u5230\u6a5f\u5b50\u4f86\u73a9(\u55da\u547c\u6211\u7684 z3 \u4e0d\u652f\u63f4\u5347\u7d1a)\uff0c\u5c31\u4e00\u8def\u62d6\u963f\u6258\u963f\u6258\uff0c\u679c\u7136\u5230\u4e86 8\/22 \u6b63\u5f0f\u7248\u51fa\u4f86\u9084\u662f\u6c92\u6709\u6a5f\u5b50\u73a9\uff0c\u4f46\u662f\u9810\u5148 Survey Android \u65b0\u7248\u7684\u8b8a\u52d5\uff0c\u5e7e\u4e4e\u662f\u7cfb\u7d71\u5ee0\u7684\u529f\u8ab2\uff0c\u56e0\u70ba\u4f60\u6c38\u9060\u4e0d\u77e5\u9053\u63a5\u4e0b\u4f86\u6703\u4e0d\u6703\u6709\u8981\u6c42\uff0c\u8981\u8b93\u4ee5\u524d\u6216\u662f\u672a\u4f86\u7684\u624b\u6a5f\u901a\u901a\u5347\u4e0a\u53bb\u3002\u56e0\u6b64\u5718\u968a\u679c\u7136\u9084\u662f\u6d3e\u4eba(Not me)\u51fa\u4f86\u7814\u7a76\u7814\u7a76\u5566\uff0c\u7531\u65bc google \u7684\u5b98\u65b9\u66f4\u65b0\u9805\u76ee\u662f\u4e0d\u65b7\u589e\u9577\u7684\uff0c\u4e14\u4e0d\u5c11\u6771\u897f\u4e5f\u6c92\u6709\u8a73\u7d30\u7684\u5be6\u52d9\u7d93\u9a57\uff0c\u6211\u5c31\u53ea\u80fd\u770b\u5230\u54ea\u5beb\u5230\u54ea\u3002\u4ee5\u4e0b\u662f\u7c21\u55ae\u4ecb\u7d39\u3002<\/p>\n<p>\u770b\u5b8c\u7684\uff0c\u6709\u88dc\u5145\u8cc7\u6599<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/multi-window.html\">Multi-Window Support \u591a\u8996\u7a97\u652f\u63f4<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/android-developers.blogspot.tw\/2016\/06\/notifications-in-android-n.html\">Notification Enhancements \u901a\u77e5\u6b04\u5f37\u5316<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/guide\/topics\/resources\/multilingual-support.html\">Multi-locale Support, More Languages\u00a0\u591a\u5730\u5340\u8a2d\u5b9a\u652f\u63f4\uff0c\u66f4\u591a\u8a9e\u8a00<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/monitoring-device-state\/doze-standby.htm\">Doze on the Go\u00a0\u79fb\u52d5\u6642\u4f11\u7720<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/topic\/performance\/background-optimization.html\">Project Svelte: Background Optimizations\u00a0\u5c08\u6848 Svelte\uff1a\u80cc\u666f\u6700\u4f73\u5316<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=H-9xKmuwawg\">Data Saver<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/reference\/android\/service\/quicksettings\/Tile.html\">Quick Settings Tile API\u00a0\u5feb\u901f\u8a2d\u5b9a\u78da API<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/tv\/tif\/content-recording.html\">Android TV \u9304\u88fd<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/articles\/security-config.html\">Network Security Configuration\u00a0\u7db2\u8def\u5b89\u5168\u6027\u5f37\u5316<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/articles\/scoped-directory-access.html\">Scoped Directory Access\u00a0\u9650\u5b9a\u7bc4\u570d\u76ee\u9304\u5b58\u53d6<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en\">Virtual Files \u865b\u64ec\u6a94\u6848<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/articles\/direct-boot.html\">Supporting Direct Boot \u76f4\u63a5\u958b\u6a5f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.android.com\/work\/\">Android for Work Updates<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/guide\/platform\/j8-jack.html?hl=en\">Java 8 Language features JAVA 8 \u652f\u63f4<\/a><\/p>\n<\/li>\n<li>\n<p>Profile-guided JIT\/AOT Compilation\u00a0\u8a2d\u5b9a\u6a94\u6307\u5f15 JIT\/AOT \u7de8\u8b6f<\/p>\n<\/li>\n<\/ol>\n<p>\u5e95\u4e0b\u662f\u9084\u6c92\u7d30\u770b\u7684\uff08\u5f85\u88dc\u5145\uff0c\u6211\u6c7a\u5b9a\u653e\u5230\u7b2c\u4e8c\u7bc7\uff09\uff0c\u4e00\u53e5\u8a71\u7d50\u8ad6<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/ndk\/guides\/graphics\/index.html\">Vulkan API<\/a>\u00a0\uff0d\u65b0\u7684 3D \u6e32\u67d3 api<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/reference\/android\/view\/SurfaceView.html\">SurfaceView<\/a>\u00a0\uff0d\u8acb\u5927\u5bb6\u7528 SurfaceView \u53d6\u4ee3 TextureView \uff0c\u6bd4\u8f03\u7701\u96fb<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en#print_svc\">Number Blocking<\/a>\uff0d\u7cfb\u7d71\u7d1a\u7684 who\u2019s call<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/reference\/android\/telecom\/CallScreeningService.html\">Call Screening<\/a>\uff0d\u7cfb\u7d71\u7d1a\u7684 who\u2019 call<\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/unicode.org\/emoji\/charts\/full-emoji-list.html\">New Emojis<\/a>\uff0d\u66f4\u591a Emojis<\/p>\n<\/li>\n<li>\n<p>[ICU4J APIs in Android](<a href=\"http:\/\/ICU4J\">http:\/\/ICU4J<\/a> APIs in Android)\u00a0\uff0d\u66f4\u5c0f\u7684 size<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en#webview\">WebView<\/a>\uff0dChrome + WebView, Together and\u00a0Multiprocess<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/guide\/topics\/graphics\/opengl.html\">OpenGL\u2122 ES 3.2 API<\/a>\uff0d\u66f4\u65b0<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/reference\/android\/accessibilityservice\/AccessibilityService.html\">Accessibility Enhancements<\/a>\u00a0\uff0dnope<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/training\/articles\/security-key-attestation.html\">Key Attestation<\/a>\u00a0\uff0dnope<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/studio\/build\/build-variants.html#signing\">APK Signature Scheme v2<\/a>\uff0d\u6539\u5584\u9a57\u8b49\u901f\u5ea6\u4e26\u589e\u5f37\u5b8c\u6574\u6027\u4fdd\u8b49<\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/www.androidpolice.com\/2016\/05\/19\/android-n-preview-3-introduces-a-new-shortcuts-helper-screen-for-physical-keyboards\/\">Keyboard Shortcuts Helper<\/a>\uff0d<strong>Meta\uff08alt\/command\uff09 + \/<\/strong> to trigger a <em>Keyboard Shortcuts<\/em> screen<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en#custom_pointer_api\">Custom Pointer API<\/a>\uff0d\u81ea\u8a02\u6e38\u6a19\u5916\u89c0<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en#sustained_performance_api\">Sustained Performance API<\/a>\uff0d\u7528\u4f86\u6e2c\u8a66 long-running apps<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developers.google.com\/vr\/android\/\">Print Service Enhancements<\/a>\uff0dnope<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en#framemetrics_api\">FrameMetricsListener API<\/a>\u00a0\uff0dmonitor its UI rendering performance\uff0cnot limited to the past 120 frames.<\/p>\n<\/li>\n<\/ol>\n<h4><a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/multi-window.html\">Multi-Window Support \u591a\u8996\u7a97\u652f\u63f4<\/a><\/h4>\n<pre><code class=\"hljs language-plaintext\">graph TD\n    subgraph MultiWindow [Android N \u591a\u91cd\u8996\u7a97\u6a21\u5f0f]\n    Split[\u5206\u5272\u756b\u9762\u6a21\u5f0f Split-Screen: \u4e0a\u4e0b\/\u5de6\u53f3 50:50 \u6216 33:67]\n    PiP[\u756b\u4e2d\u756b\u6a21\u5f0f Picture-in-Picture: \u61f8\u6d6e\u5c0f\u7a97\u64ad\u653e\u5f71\u7247]\n    Freeform[\u81ea\u7531\u5f62\u5f0f\u8996\u7a97 Freeform: \u985e\u4f3c\u684c\u9762\u591a\u8996\u7a97\u62d6\u66f3]\n    end<\/code><\/pre>\n<p>Android N \u65b0\u589e\u4e00\u6b21\u986f\u793a\u591a\u500b\u61c9\u7528\u7a0b\u5f0f\u7684\u652f\u63f4\u3002 \u5728\u624b\u6301\u5f0f\u88dd\u7f6e\u4e0a\uff0c\u5169\u500b\u61c9\u7528\u7a0b\u5f0f\u53ef\u4ee5\u5728\u300c\u5206\u5272\u756b\u9762\u300d\u6a21\u5f0f\u4e2d\u4e26\u6392\u6216\u4e0a\u4e0b\u6392\u5217\u3002 \u5728\u96fb\u8996\u88dd\u7f6e\u4e0a\uff0c\u61c9\u7528\u7a0b\u5f0f\u80fd\u4f7f\u7528\u300c\u5b50\u6bcd\u756b\u9762\u300d\u6a21\u5f0f\uff0c\u5728\u4f7f\u7528\u8005\u8207\u53e6\u4e00\u500b\u61c9\u7528\u7a0b\u5f0f\u4e92\u52d5\u6642\u6301\u7e8c\u64ad\u653e\u5f71\u7247\u3002<\/p>\n<p>\u9019\u529f\u80fd\u5176\u5be6\u4e4b\u524d\u5c31\u6709\u5176\u4ed6\u5927\u5ee0\u505a\u904e\uff0c\u6211\u60f3\u4e3b\u56e0\u5176\u5be6\u5f88\u7c21\u55ae\uff0c\u5c31\u662f\u5728\u5927\u87a2\u5e55\u6a5f\u5668\u4e0a\uff0c\u9019\u6a23\u7684\u64cd\u4f5c\u53ef\u4ee5\u6709\u6548\u5229\u7528\u6240\u6709\u7684\u756b\u9762\uff0c\u662f\u500b\u975e\u5e38\u76f4\u89ba\u7684\u529f\u80fd\u3002\u4f46\u662f\u76f8\u5c0d\u7684\u5c0d\u88dd\u7f6e\u6548\u80fd\u66f4\u52a0\u8981\u6c42\uff0c\u5c24\u5176\u662f\u5c0d RAM\uff0c\u9019\u6a23\u7684\u529f\u80fd\u5be6\u5728\u5f88\u96e3\u60f3\u50cf\u5728 256 MB \u7684\u624b\u6a5f\u4e0a\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n<p>\u81f3\u65bc\u5982\u4f55\u4f7f\u7528\uff0c\u5b98\u7db2\u662f\u9019\u6a23\u8aaa<\/p>\n<p>\u4f7f\u7528\u8005\u53ef\u4ee5\u900f\u904e\u4e0b\u5217\u65b9\u5f0f\u4f86\u5207\u63db\u591a\u8996\u7a97\u6a21\u5f0f\uff1a<\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u4f7f\u7528\u8005\u958b\u555f<a href=\"https:\/\/developer.android.com\/guide\/components\/recents.html?hl=zh-tw\">\u7e3d\u89bd\u756b\u9762<\/a>\u4e26\u9577\u6309\u6d3b\u52d5\u6a19\u984c\uff0c\u5c31\u53ef\u4ee5\u5c07\u8a72\u6a19\u984c\u62d6\u66f3\u5230\u756b\u9762\u9192\u76ee\u63d0\u793a\u7684\u90e8\u5206\uff0c\u5c07\u6d3b\u52d5\u653e\u5165\u591a\u8996\u7a97\u6a21\u5f0f\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u4f7f\u7528\u8005\u9577\u6309\u300c\u7e3d\u89bd\u300d\u6309\u9215\uff0c\u88dd\u7f6e\u6703\u5c07\u76ee\u524d\u7684\u6d3b\u52d5\u653e\u5165\u591a\u8996\u7a97\u6a21\u5f0f\uff0c\u4e26\u958b\u555f\u7e3d\u89bd\u756b\u9762\uff0c\u8b93\u4f7f\u7528\u8005\u9078\u64c7\u8981\u5206\u4eab\u87a2\u5e55\u7684\u53e6\u4e00\u500b\u6d3b\u52d5\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u8005\u53ef\u4ee5\u5728\u6d3b\u52d5\u5206\u4eab\u87a2\u5e55\u6642\uff0c\u5c07\u4e00\u500b\u6d3b\u52d5\u4e2d\u7684\u8cc7\u6599<a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/drag-drop.html?hl=zh-tw\">\u62d6\u653e<\/a>\u5230\u53e6\u4e00\u500b\u6d3b\u52d5\u3002 (\u4e4b\u524d\uff0c\u4f7f\u7528\u8005\u53ea\u80fd\u5728\u55ae\u4e00\u6d3b\u52d5\u5167\u62d6\u653e\u8cc7\u6599)\u3002<\/p>\n<p>ps. \u7e3d\u89bd\u756b\u9762\u5c31\u662f recent app \u9801\u9762\uff0c\u4e5f\u5c31\u662f\u5927\u5bb6\u624b\u6a5f\u6309\u4e0b\u53f3\u4e0b\u6216\u662f\u5de6\u4e0b\u7684\u65b9\u584a\u6309\u9215\u6703\u51fa\u73fe\u7684\u756b\u9762\uff0c\u8001\u5be6\u8aaa\u6211\u89ba\u5f97\u5343\u8a00\u842c\u8a9e\u6bd4\u4e0d\u4e0a\u4e00\u6bb5<a href=\"https:\/\/www.youtube.com\/watch?v=laHfmVN01FQ\">\u5f71\u7247\u6f14\u793a<\/a>\u3002<\/p>\n<p>\u770b\u5230\u9019\u908a\u6ce8\u610f\u5230\u5b98\u7db2\u63d0\u5230\u7684<\/p>\n<p>\u300eManufacturers of larger devices can choose to enable freeform mode, in which the user can freely resize each activity. If the manufacturer enables this feature, the device offers freeform mode in addition to split-screen mode.\u300f<\/p>\n<p>\u9019\u500b\u4e5f\u662f\u6587\u5b57\u6558\u8ff0\u4e26\u4e0d\u592a\u597d\u7406\u89e3\uff0c\u7c21\u55ae\u4f86\u8aaa\u5c31\u662f\u53ef\u4ee5\u50cf\u5e73\u5e38\u64cd\u4f5c\u96fb\u8166\uff0c\u53ef\u4ee5\u81ea\u7531\u7e2e\u653e\u8996\u7a97\uff0c\u5c24\u5176\u662f\u5728\u5411\u96fb\u8996\u9019\u7a2e\u8d85\u5927\u578b\u756b\u9762\u4e0a\uff0c\u500b\u4eba\u89ba\u5f97\u6240\u6709\u505a Android \u96fb\u8996\u68d2\u7684\u5ee0\u5546\u90fd\u8981\u597d\u597d\u6ce8\u610f\u9019\u584a\uff0c\u4e0d\u904e\u4e5f\u662f\u9700\u8981 app vendor \u53bb\u652f\u63f4\u3002<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- AndroidManifest.xml \u652f\u63f4\u591a\u8996\u7a97\u8207\u81ea\u7531\u7e2e\u653e (Freeform) \u914d\u7f6e --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">activity<\/span>\n    <span class=\"hljs-attr\">android:name<\/span>=<span class=\"hljs-string\">&quot;.MainActivity&quot;<\/span>\n    <span class=\"hljs-attr\">android:resizeableActivity<\/span>=<span class=\"hljs-string\">&quot;true&quot;<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">layout<\/span>\n        <span class=\"hljs-attr\">android:defaultHeight<\/span>=<span class=\"hljs-string\">&quot;500dp&quot;<\/span>\n        <span class=\"hljs-attr\">android:defaultWidth<\/span>=<span class=\"hljs-string\">&quot;600dp&quot;<\/span>\n        <span class=\"hljs-attr\">android:minHeight<\/span>=<span class=\"hljs-string\">&quot;400dp&quot;<\/span>\n        <span class=\"hljs-attr\">android:minWidth<\/span>=<span class=\"hljs-string\">&quot;300dp&quot;<\/span> \/&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">activity<\/span>&gt;<\/span><\/code><\/pre>\n<p><a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/multi-window.html\">\u958b\u767c\u65b9\u9762\u5c31\u4e0d\u591a\u8aaa\uff0c\u8981\u6ce8\u610f\u7684\u6771\u897f\u4e0d\u5c11\u3002<\/a>\u9700\u8981\u6ce8\u610f\u7684\u662f multi-window activity \u7684\u751f\u547d\u9031\u671f\u57fa\u672c\u4e0a\u8ddf\u539f\u672c\u4e00\u6a23\uff0c\u4f46\u662f\u4ed4\u7d30\u60f3\u60f3\u5c31\u77e5\u9053\u591a\u8996\u7a97\u64cd\u4f5c\u6642\u5c31\u6703\u6709\u5176\u4e2d\u4e00\u500b\u624d\u662f focus \u7684 window\uff0c\u800c\u6c92\u6709 focus \u7684 window activity \u90fd\u662f\u8655\u5728 onPause \u968e\u6bb5\uff0c\u4e26\u975e onStop \u968e\u6bb5\uff0c\u76f8\u5c0d\u5730\u62ff\u5230 focus \u7684 windows activity \u6703\u9032\u5165 onResume\u3002<\/p>\n<p>\u53e6\u5916\u5c31\u662f\u6211\u5f88\u597d\u5947 home app \u6703\u662f\u600e\u9ebc\u8655\u7406 multi-windows \uff0c\u4e4b\u5f8c\u62ff\u5230\u6a5f\u5b50\u4e00\u5b9a\u8981\u8a66\u8a66\u770b\u3002\u6b64\u5916 task queue \u7684\u8655\u7406\u4e5f\u662f\u9700\u8981\u4ed4\u7d30\u7814\u7a76\u3002ps. multi-windows mode \u4e0b\u00a0Android N\u662f\u53ef\u4ee5\u652f\u63f4\u5169\u500bview (\u5169\u500bActivities\u4e4b\u9593)\u4ea4\u63db\u8cc7\u8a0a(<a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/multi-window.html\">multi-window<\/a>);\u5be6\u4f5c\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/view\/View.OnDragListener.html\">View.OnDragListener<\/a>\uff0c\u50b3\u905e <a href=\"https:\/\/developer.android.com\/reference\/android\/content\/ClipData.html\">ClipData<\/a>\u3002(<a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/drag-drop.html\">Drag and Drap<\/a>)<\/p>\n<p><strong>\u800c\u5728\u6b64\u9805\u76ee\u4e4b\u4e0b\u6240\u884d\u751f\u7684\u5c31\u662f\u300ePicture in picture(\u5b50\u6bcd\u756b\u9762)\u300f\uff0c<\/strong><a href=\"https:\/\/www.youtube.com\/watch?v=TxAbht2DkyU\">\u5f71\u7247\u6f14\u793a<\/a>\u00a0\uff0c(TV only)<\/p>\n<blockquote><\/blockquote>\n<p>\u7576\u4f7f\u7528\u8005\u5f9e\u5f71\u7247\u8fd4\u56de\u700f\u89bd\u5176\u4ed6\u5167\u5bb9\uff0c\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u53ef\u4ee5\u5c07\u5f71\u7247\u79fb\u5165 PIP \u6a21\u5f0f\u3002<\/p>\n<p>\u7576\u4f7f\u7528\u8005\u89c0\u770b\u5230\u5f71\u7247\u5167\u5bb9\u7684\u7d50\u5c3e\u6642\uff0c\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u53ef\u5c07\u5f71\u7247\u5207\u63db\u5230 PIP \u6a21\u5f0f\u3002<\/p>\n<p>\u4e3b\u756b\u9762\u986f\u793a\u7cfb\u5217\u4e2d\u4e0b\u4e00\u96c6\u7684\u9810\u544a\u6216\u6458\u8981\u8cc7\u8a0a\u6642\u3002\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u53ef\u4ee5\u70ba\u4f7f\u7528\u8005\u63d0\u4f9b\u4e00\u500b\u89c0\u8cde\u5f71\u7247\u6642\u4f47\u5217\u5176\u4ed6\u5167\u5bb9\u7684\u65b9\u5f0f\u3002 \u7576\u4e3b\u756b\u9762\u986f\u793a\u5167\u5bb9\u9078\u64c7\u6d3b\u52d5\u6642\uff0c\u5f71\u7247\u7e7c\u7e8c\u5728 PIP \u6a21\u5f0f\u4e2d\u64ad\u653e\u3002<\/p>\n<p>\u958b\u767c\u4e0a\u9700\u8981\u6ce8\u610f\u7684\u57fa\u672c\u8ddf multi-windows \u662f\u4e00\u6a23\u7684\uff0c\u751f\u547d\u9031\u671f\uff0c\u901a\u5e38\u9032\u5165 onPause \u5f8c\uff0c\u5f71\u7247\u5c31\u6703\u505c\u6b62\u64ad\u653e\uff0c\u56e0\u6b64\u5fc5\u9808\u5728 onPause \u968e\u6bb5\u4f5c\u4e00\u4e9b\u8655\u7406\uff0c\u8b93\u5f71\u7247\u7e7c\u7e8c\u64ad\u653e\uff0c\u540c\u6a23\u7684\u4e5f\u5fc5\u9808\u5728 onResume \u968e\u6bb5\u4f5c\u76f8\u5c0d\u8655\u7406\u3002\u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f pip mode \u662f 240\u00d7135 dp\u3002\uff08\u9019\u5f88\u660e\u986f\u662f\u70ba\u4e86 tv \u8a2d\u8a08\u7684\uff0c\u53ef\u662f\u76ee\u524d\u611f\u89ba\u5e02\u9762\u4e0a\u597d\u50cf\u9084\u6c92\u6709\u51fa\u65d7\u8266\u6b3e\u7684\u96fb\u8996\uff0c\u540c\u6642\u8655\u7406\u5b50\u6bcd\u756b\u9762\u611f\u89ba\u5f88\u5403\u8cc7\u6e90\uff09\u3002<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-comment\">\/\/ \u9032\u5165\u5b50\u6bcd\u756b\u9762 (Picture-in-Picture) \u6a21\u5f0f (API 24+ Android TV &amp; Handheld)<\/span>\n<span class=\"hljs-keyword\">if<\/span> (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N &amp;&amp; \n    getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) {\n    enterPictureInPictureMode();\n}<\/code><\/pre>\n<h4><\/h4>\n<h4><a href=\"https:\/\/android-developers.blogspot.tw\/2016\/06\/notifications-in-android-n.html\">Notification Enhancements \u901a\u77e5\u6b04\u5f37\u5316<\/a><\/h4>\n<p>\u9019\u90e8\u4efd\u6709\u4ee5\u4e0b\u4e94\u5927\u6539\u7248<\/p>\n<p><strong>1. Template updates<\/strong>: We\u2019re updating notification templates to put a new emphasis on hero image and avatar. Developers will be able to take advantage of the new templates with minimal adjustments in their code.<\/p>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u901a\u77e5\u6b04\u65b0\u7279\u6027 (Bundled Notifications &amp; Direct Reply)]\n+-------------------------------------------------------------+\n|  MessagingApp \u2022 3 new messages                       10:24  |\n|  Alice: Hey, are you coming?                                |\n|  Bob: The meeting room is ready.                            |\n|  [ Reply directly...                                     ]  |\n+-------------------------------------------------------------+<\/code><\/pre>\n<p><strong>\u6a23\u677f\u66f4\u65b0<\/strong>\uff0c\u8001\u5be6\u8aaa\u6211\u89ba\u5f97\u6c92\u5565\u597d\u8aaa\uff0c\u770b\u4e0a\u9762\u5716\u6700\u5feb\u3002\u4f7f\u7528\u8005\u53ef\u4ee5\u66f4\u52a0\u7c21\u55ae\u7684\u63db\u6210\u65b0\u7248\u7684ui<\/p>\n<p><strong>2. Messaging style customization<\/strong>: You can customize more of the user interface labels associated with your notifications using the <code>MessagingStyle\u00a0<\/code>class. You can configure the message, conversation title, and content view.<\/p>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u901a\u77e5\u6b04\u65b0\u7279\u6027 (Bundled Notifications &amp; Direct Reply)]\n+-------------------------------------------------------------+\n|  MessagingApp \u2022 3 new messages                       10:24  |\n|  Alice: Hey, are you coming?                                |\n|  Bob: The meeting room is ready.                            |\n|  [ Reply directly...                                     ]  |\n+-------------------------------------------------------------+<\/code><\/pre>\n<p><strong>\u8a0a\u606f\u98a8\u683c\u5ba2\u88fd\u5316<\/strong>\uff0c\u5176\u5be6\u9019\u500b\u5f88\u65b9\u4fbf\uff0c\u53ef\u4ee5\u6839\u64da\u60c5\u6cc1\u5957\u5165\u4e0d\u540c\u7684 message style \uff0c\u5176\u5be6\u4ee5\u524d\u5c31\u53ef\u4ee5\u7528 \u5ba2\u88fd\u5316 notification ui \u7684\u65b9\u5f0f\u9054\u5230\uff0c\u4f46\u9019\u500b\u5f88\u660e\u986f google \u591a\u500b\u898f\u7bc4\uff0c\u8b93\u5927\u5bb6\u66f4\u597d\u505a\u4e8b\u3002<\/p>\n<p><strong>3.\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=2ZQ1D003g14\">Bundled notifications:<\/a><\/strong> The system can group messages together, for example by message topic, and display the group. A user can take actions, such as Dismiss or Archive, on them in place. If you\u2019ve implemented notifications for Android Wear, you\u2019ll already be familiar with this model.<\/p>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u901a\u77e5\u6b04\u65b0\u7279\u6027 (Bundled Notifications &amp; Direct Reply)]\n+-------------------------------------------------------------+\n|  MessagingApp \u2022 3 new messages                       10:24  |\n|  Alice: Hey, are you coming?                                |\n|  Bob: The meeting room is ready.                            |\n|  [ Reply directly...                                     ]  |\n+-------------------------------------------------------------+<\/code><\/pre>\n<p><strong>\u901a\u77e5\u6b78\u7fa4<\/strong>\uff0c\u9019\u500b\u7684\u4e2d\u6587\u5be6\u5728\u4e0d\u597d\u7ffb\uff0c\u770b\u4e86\u4e00\u4e0b i\/o \u5f71\u7247\u4ecb\u7d39\uff0c\u500b\u4eba\u89ba\u5f97\u9019\u500b\u6bd4\u8f03\u7b26\u5408\u610f\u7fa9\uff0c\u904e\u53bb\u5728\u901a\u77e5\u6b04\u88e1\u5176\u5be6\u6c92\u5565\u53ef\u4ee5\u73a9\u5f97\uff0c\u56e0\u70ba\u6240\u6709\u7684\u901a\u77e5\u90fd\u662f\u7167\u6642\u9593\u6392\u5e8f\u597d\uff0c\u5f7c\u6b64\u4e4b\u9593\u90fd\u662f\u7368\u7acb\u7684\u3002\u4f46\u4e5f\u4e0d\u662f\u8aaa\u4e00\u5b9a\u4e0d\u884c\uff0c\u5982\u679c\u6709\u958b\u767c email \u7684\u4eba\u5c31\u6703\u77e5\u9053\u6709\u500b style \u53eb\u505a inbox \uff0c\u53ef\u4ee5\u4f5c\u5230\u985e\u4f3c\u7684\u4e8b\u60c5\u4f46\u662f\u8655\u7406\u5be6\u5728\u9ebb\u7169\u3002 \u73fe\u5728\u591a\u4e00\u500b setGroup() and setGroupSummary() \u5e6b\u52a9\u5404\u4f4d\u66f4\u65b9\u4fbf\u8655\u7406\u9019\u4ef6\u4e8b\u60c5\u3002\u6b64\u5916\u5728 api 24 \u4ee5\u4e0a \uff0c\u7cfb\u7d71\u6703\u81ea\u52d5\u628a4\u689d\u901a\u77e5\u4ee5\u4e0a\u6b78\u985e\u6210\u4e00\u7d44\uff0c\u5982\u679c\u6015\u88ab\u7cfb\u7d71\u5f04\u7684\u4e0d\u597d\u770b\uff0c\u8acb\u81ea\u5df1\u5148\u8655\u7406\u5427\u3002<\/p>\n<p><strong>4.\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=Zg4v9G-lku8\">Direct reply:<\/a><\/strong> For real-time communication apps, the Android system supports inline replies so that users can quickly respond to an SMS or text message directly within the notification interface.<\/p>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u901a\u77e5\u6b04\u65b0\u7279\u6027 (Bundled Notifications &amp; Direct Reply)]\n+-------------------------------------------------------------+\n|  MessagingApp \u2022 3 new messages                       10:24  |\n|  Alice: Hey, are you coming?                                |\n|  Bob: The meeting room is ready.                            |\n|  [ Reply directly...                                     ]  |\n+-------------------------------------------------------------+\n```\u76f4\u63a5\u56de\u61c9\uff0c\u5c31\u6211\u6240\u77e5\u4ee5\u5f80\u8981\u56de\u8986\u4fe1\u4ef6\u6216\u662f sns\uff0c notification \u6700\u591a\u80fd\u4f5c\u5230\u7684\u5c31\u662f\u5229\u7528 pendingIntent \u53bb\u958b\u555f activity \u9032\u884c\u56de\u61c9\u3002\u800c\u9019\u6b21\u591a\u4e86\u4e00\u500b\u65b0\u7684 api \u5c31\u662f RemoteInput\uff0c\u914d\u5408 message style \u53ef\u4ee5\u4f5c\u5230\u76f4\u63a5\u5728 notificaion \u4e0a\u8f38\u5165\u6587\u5b57\uff0c\u76f4\u63a5\u56de\u8986\uff0c\u800c\u4e0d\u9700\u8981\u96e2\u958b\u901a\u77e5\u6b04\u3002\u611f\u89ba\u5c31\u662f\u70ba\u4e86 Android wear \u6240\u8a2d\u8a08\u7684\uff0c\u5be6\u969b\u4e0a Android wear \u4e0a\u65e9\u5df2\u7d93\u6709\u4e86\u3002\n\n**5. Custom views**: Two new APIs enable you to leverage system decorations, such as notification headers and actions, when using custom views in notifications.\n\n**\u756b\u9762\u5ba2\u88fd\u5316**\uff0c\u4e3b\u8981\u5c31\u662f\u591a\u4e86\u5169\u500b api style\uff0c\u9019\u4e00\u6a23\u6703\u9700\u8981\u642d\u914d message style \u6703\u66f4\u597d\u3002\n\n[Notification.DecoratedCustomViewStyle:](https:\/\/developer.android.com\/reference\/android\/app\/Notification.DecoratedCustomViewStyle.html)\u00a0Notification style for custom views that are decorated by the system.\n\n[Notification.DecoratedMediaCustomViewStyle](https:\/\/developer.android.com\/reference\/android\/app\/Notification.DecoratedMediaCustomViewStyle.html):Notification style for media custom views that are decorated by the system.\n\n\u7e3d\u7d50:\u9019\u6b21\u6539\u52d5\u9817\u5927\uff0c\u4e0a\u6b21\u6709\u6bd4\u8f03\u5927\u7684\u6539\u7248\u611f\u89ba\u5c31\u662f notification service listener\u3002\u800c\u9019\u6b21\u6539\u7248\u5247\u662f\u8b93\u4f7f\u7528\u8005\u53ef\u4ee5\u6709\u66f4\u591a\u64cd\u4f5c\u5728 notification\u4e0a\u9762\uff08\u53d7\u76ca\u6700\u660e\u986f\u7684\u5c31\u662f email \u9019\u985e app (gmail)\uff09\uff0c\u5176\u5be6\u9019\u5169\u7a2e\u6539\u7248\u90fd\u662f\u70ba\u4e86\u8b93 notification \u4e0d\u518d\u50cf\u662f\u6f51\u51fa\u53bb\u7684\u6c34\u4e00\u6a23\uff0c\u5c31\u53ea\u662f\u500b\u901a\u77e5\uff0c\u800c\u662f\u63d0\u9ad8\u4f7f\u7528\u8005\uff0cactivity\u548c notification \u4e4b\u9593\u7684\u95dc\u806f\u6027\u3002ps.\u751a\u81f3\u5728\u5b98\u65b9 blog \u4e0a\u63d0\u5230 Android N \u7684 N \u5c31\u662f notification\u3002\n\n\u00a0\n\n#### [Multi-locale Support, More Languages\u00a0\u591a\u5730\u5340\u8a2d\u5b9a\u652f\u63f4\uff0c\u66f4\u591a\u8a9e\u8a00](https:\/\/developer.android.com\/guide\/topics\/resources\/multilingual-support.html)\n\nAndroid N \u73fe\u5728\u53ef\u8b93\u4f7f\u7528\u8005\u5728 [\u8a2d\u5b9a] \u4e2d\u9078\u53d6**\u591a\u500b\u5730\u5340\u8a2d\u5b9a**\uff0c\u4ee5\u4fbf\u4ee5\u66f4\u597d\u7684\u65b9\u5f0f\u652f\u63f4\u96d9\u8a9e\u8a00\u4f7f\u7528\u6848\u4f8b\u3002\u61c9\u7528\u7a0b\u5f0f\u53ef\u4ee5\u4f7f\u7528\u65b0\u7684 API \u53d6\u5f97\u4f7f\u7528\u8005\u9078\u53d6\u7684\u5730\u5340\u8a2d\u5b9a\uff0c\u7136\u5f8c\u70ba\u591a\u5730\u5340\u8a2d\u5b9a\u4f7f\u7528\u8005\u63d0\u4f9b\u66f4\u7cbe\u7d30\u7684\u4f7f\u7528\u8005\u9ad4\u9a57 \u2014 \u4f8b\u5982\u4ee5\u591a\u8a9e\u8a00\u986f\u793a\u641c\u5c0b\u7d50\u679c\uff0c\u4ee5\u53ca\u4e0d\u70ba\u4f7f\u7528\u8005\u5df2\u7d93\u719f\u77e5\u8a9e\u8a00\u7684\u7db2\u9801\u63d0\u4f9b\u7ffb\u8b6f\u3002\n\n\u7c21\u55ae\u4f86\u8aaa\uff0c\u904e\u53bb\u4f60\u53ea\u80fd\u9078\u64c7\u4e00\u7a2e\u8a9e\u8a00\u4f5c\u70ba\u4f7f\u7528\u74b0\u5883\uff0c\u5047\u8a2d\u662f\u7e41\u9ad4\u4e2d\u6587\uff0c\u5982\u679c App \u4e26\u4e0d\u652f\u63f4\u7e41\u9ad4\u4e2d\u6587\u90a3\u5c31\u53ea\u80fd\u662f\u9810\u8a2d\u82f1\u6587\uff0c\u4f46\u73fe\u5728\u4f60\u53ef\u4ee5\u5728\u300e\u8a2d\u5b9a\u300f\u88e1\u9078\u64c7\u591a\u500b\u4f60\u6700\u7fd2\u6163\u7684\u8a9e\u8a00\u8207\u512a\u5148\u6b0a\uff0c\u5047\u8a2d\u662f\u7b2c\u4e00\u512a\u5148\u662f\u6cd5\u6587\uff08fr_cj\uff09\uff0c\u7b2c\u4e8c\u662f\u7fa9\u5927\u5229\u6587(it_ch)\uff0c\u5982\u679c App \u6c92\u6709\u652f\u63f4\u6cd5\u6587\uff0c\u90a3\u5c31\u6703\u81ea\u52d5\u627e\u7fa9\u5927\u5229\u6587\uff0c\u5982\u679c\u9084\u662f\u627e\u4e0d\u5230\uff0c\u90a3\u624d\u6703\u8df3\u5230\u82f1\u6587\u3002\n\n\u5c0d\u65bc\u570b\u7c4d\u4ee5\u53ca\u5340\u78bc\u7684\u5c0d\u61c9\u65b9\u5f0f\u4e5f\u6539\u8b8a\u3002\u5e95\u4e0b\u7528\u5e7e\u5f35\u5716\u8868\u793a\u66f4\u52a0\u6e05\u695a\n\n```text\n[Android 7.0 \u591a\u8a9e\u8a00\u504f\u597d\u6bd4\u5c0d (LocaleList Priority)]\n1. \u7e41\u9ad4\u4e2d\u6587 (\u53f0\u7063) [zh-TW]  -&gt; \u512a\u5148\u6bd4\u5c0d values-zh-rTW\n2. \u82f1\u6587 (\u7f8e\u570b) [en-US]       -&gt; \u6b21\u9078\u6bd4\u5c0d values-en-rUS\n3. \u9810\u8a2d\u8a9e\u7cfb                 -&gt; Fallback values\/strings.xml<\/code><\/pre>\n<p>**\u7b2c\u4e00\u5f35\u5716\uff1a**\u9019\u662f Android N \u4e4b\u524d\u7684\u4f5c\u6cd5\uff0c\u7576\u4f7f\u7528\u8005\u53ea\u8a2d\u5b9a fr_CH \uff0c\u4f46 App Resources \u53ea\u6709 en , de_DE , es_ES , fr_FR , it_IT\uff0c\u90a3\u4ed6\u7684\u6bd4\u5c0d\u904e\u7a0b\u5c31\u6703\u662f<\/p>\n<ol>\n<li>\u5148\u78ba\u8a8d fr_CH =&gt; \u6c92\u6709 \u00a0 2. \u63a5\u8005\u5c0d\u61c9\u570b\u7c4d fr =&gt; \u6c92\u6709 3. \u6700\u5f8c\u53ea\u597d\u4f7f\u7528\u9810\u8a2d en<\/li>\n<\/ol>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u591a\u8a9e\u8a00\u504f\u597d\u6bd4\u5c0d (LocaleList Priority)]\n1. \u7e41\u9ad4\u4e2d\u6587 (\u53f0\u7063) [zh-TW]  -&gt; \u512a\u5148\u6bd4\u5c0d values-zh-rTW\n2. \u82f1\u6587 (\u7f8e\u570b) [en-US]       -&gt; \u6b21\u9078\u6bd4\u5c0d values-en-rUS\n3. \u9810\u8a2d\u8a9e\u7cfb                 -&gt; Fallback values\/strings.xml<\/code><\/pre>\n<p>**\u7b2c\u4e8c\u5f35\u5716\uff1a**\u9019\u662f Android N \u7684\u4f5c\u6cd5\uff0c\u7576\u4f7f\u7528\u8005\u53ea\u8a2d\u5b9a fr_CH \uff0c\u4f46 App Resources \u53ea\u6709 en , de_DE , es_ES , fr_FR , it_IT\uff08\u540c\u4e0a\uff09\uff0c\u90a3\u4ed6\u7684\u6bd4\u5c0d\u904e\u7a0b\u5c31\u6703\u662f<\/p>\n<ol>\n<li>\u5148\u78ba\u8a8d fr_CH =&gt; \u6c92\u6709 \u00a0 \u00a02. \u63a5\u8005\u5c0d\u61c9\u570b\u7c4d fr =&gt; \u4e5f\u6c92\u6709 \u00a0 3.\u627e\u627e\u770b\u6709\u6c92\u6709 Child \u5340\u78bc\u5c0d\u61c9\u5230\uff0c\u5c31\u662f fr_FR \u00a04. \u00a0\u5c31\u6c7a\u5b9a\u662f fr_FR<\/li>\n<\/ol>\n<pre><code class=\"hljs language-plaintext\">[Android 7.0 \u591a\u8a9e\u8a00\u504f\u597d\u6bd4\u5c0d (LocaleList Priority)]\n1. \u7e41\u9ad4\u4e2d\u6587 (\u53f0\u7063) [zh-TW]  -&gt; \u512a\u5148\u6bd4\u5c0d values-zh-rTW\n2. \u82f1\u6587 (\u7f8e\u570b) [en-US]       -&gt; \u6b21\u9078\u6bd4\u5c0d values-en-rUS\n3. \u9810\u8a2d\u8a9e\u7cfb                 -&gt; Fallback values\/strings.xml<\/code><\/pre>\n<p>\u7b2c\u4e09\u5f35\u5716\uff1a\u9019\u662f\u5982\u679c\u8a2d\u5b9a\u5169\u7a2e\u4ee5\u4e0a\u9810\u8a2d\u8a9e\u8a00 P1: fr_CH , P2: it_CH\uff0c\u4f46 App Resources \u53ea\u6709 en , de_DE , es_ES , it_IT\uff0c\u90a3\u4ed6\u7684\u6bd4\u5c0d\u904e\u7a0b\u5c31\u6703\u662f<\/p>\n<ol>\n<li>\u5148\u78ba\u8a8d\u7b2c\u4e00\u512a\u5148 fr_CH =&gt; \u6c92\u6709 \u00a0 \u00a02. \u63a5\u8005\u770b\u570b\u7c4d fr =&gt; \u4e5f\u6c92\u6709 \u00a0 \u00a03.\u00a0\u627e\u627e\u770b\u6709\u6c92\u6709 Child \u5340\u78bc\u5c0d\u61c9\u5230 =&gt; \u9084\u662f\u6c92\u6709 \u00a04. \u90a3\u958b\u59cb\u627e P2:it_CH \u00a0=&gt; \u4f9d\u7136\u6c92\u6709 \u00a0 5. \u627e\u570b\u7c4d it =&gt; \u5c31\u662f\u6c92\u6709 \u00a0 6. \u90a3\u627e\u627e\u6709\u6c92\u6709 Child \u5340\u78bc\u5c0d\u61c9\u5230\uff0c\u5c31\u662f it_IT \u00a0 \u00a0 \u00a07. \u5c31\u6c7a\u5b9a\u662f it_IT<\/li>\n<\/ol>\n<p>\u7e3d\u7d50\uff1a\u70ba\u4e86\u52a0\u5feb\u6279\u914d\u901f\u5ea6\uff0c\u958b\u767c\u8005\u6700\u597d\u80fd\u66f4\u52a0\u7cbe\u6e96\u7684\u7d66\u4e88\u8cc7\u6e90\u5c0d\u61c9\u3002\u5c0d\u4f7f\u7528\u8005\u4e5f\u662f\u4e00\u5927\u65b9\u4fbf\uff0c\u6709\u4eba\u5c31\u662f\u53ea\u770b\u7684\u61c2 \u4e2d\u6587\u548c\u65e5\u6587\uff0cAndroid \u6bcf\u6b21\u6c92\u4e2d\u6587\u5c31\u8df3\u5230\u82f1\u6587\uff0c\u7169\u4e0d\u7169\u963f<\/p>\n<p>\u00a0<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/training\/monitoring-device-state\/doze-standby.htm\">Doze on the Go\u00a0\u79fb\u52d5\u6642\u4f11\u7720<\/a><\/h4>\n<pre><code class=\"hljs language-plaintext\">gantt\n    title Android 7.0 Doze on the Go (\u5169\u968e\u6bb5\u4f11\u7720\u6a5f\u5236)\n    dateFormat X\n    axisFormat %s\n    section \u87a2\u5e55\u95dc\u9589\u4e14\u79fb\u52d5\u4e2d (Light Doze)\n    \u9650\u5236\u7db2\u8def\/JobScheduler      :active, 0, 30\n    \u7dad\u8b77\u7a97\u53e3 (Maintenance Window) :crit, 30, 35\n    \u9650\u5236\u7db2\u8def\/JobScheduler      :active, 35, 75\n    section \u8a2d\u5099\u975c\u6b62\u653e\u7f6e (Deep Doze)\n    \u559a\u9192\u9396\u9650\u5236 (WakeLocks)     :crit, 75, 120\n    \u9b27\u9418\u8207 GPS \u5b8c\u5168\u51cd\u7d50        :crit, 120, 180\n```Android 6.0 \u5f15\u9032\u4f11\u7720\u529f\u80fd\uff0c\u9019\u662f\u53ef\u7bc0\u7701\u96fb\u6c60\u96fb\u529b\u7684\u7cfb\u7d71\u6a21\u5f0f\uff0c\u5b83\u6703\u5728\u88dd\u7f6e\u9592\u7f6e\u6642 (\u4f8b\u5982\u653e\u5728\u684c\u5b50\u4e0a\u6216\u62bd\u5c5c\u4e2d) \u5ef6\u5f8c\u61c9\u7528\u7a0b\u5f0f\u7684 CPU \u8207\u7db2\u8def\u6d3b\u52d5\u3002\n\n\u73fe\u5728 Android N \u4e2d\u7684\u4f11\u7720\u529f\u80fd\u66f4\u9032\u4e00\u6b65\u9032\u5c55\uff0c\u300e\u53ef\u5728\u79fb\u52d5\u6642\u7bc0\u7701\u96fb\u6c60\u96fb\u529b\u300f\u3002\u53ea\u8981\u87a2\u5e55\u95dc\u9589\u4e00\u6bb5\u6642\u9593\u4e14\u88dd\u7f6e\u62d4\u9664\u96fb\u6e90\u7684\u60c5\u6cc1\u4e0b\uff0c\u4f11\u7720\u529f\u80fd\u5c31\u6703\u5c07\u719f\u6089\u7684 CPU \u8207\u7db2\u8def\u9650\u5236\u7684\u5b50\u96c6\u5957\u7528\u5230\u61c9\u7528\u7a0b\u5f0f\uff08Doze applies a subset of the familiar CPU and network restrictions to apps\uff09\u3002\u9019\u8868\u793a\u5373\u4f7f\u4f7f\u7528\u8005\u5c07\u88dd\u7f6e\u653e\u5728\u53e3\u888b\u5167\u6642\u4e5f\u53ef\u4ee5\u7bc0\u7701\u96fb\u6c60\u96fb\u529b\u3002\n\n\u539f\u672cAndroid M \u7684\u4f11\u7720\u60c5\u6cc1\u53ea\u6709\u4ee5\u4e0b\n\n* \u88dd\u7f6e\u9592\u7f6e\uff08\u4e0d\u5305\u542b\u79fb\u52d5\uff09\n\n* \u87a2\u5e55\u95dc\u9589\n\n* \u88dd\u7f6e\u62d4\u9664\u96fb\u6e90\n\n\u90a3\u9ebc\u300e\u4f11\u7720\u529f\u80fd\u5c31\u6703\u5c07\u719f\u6089\u7684 CPU \u8207\u7db2\u8def\u9650\u5236\u7684\u5b50\u96c6\u300f\u9019\u53e5\u662f\u5565\uff1f\u770b\u4e2d\u82f1\u6587\u90fd\u4e0d\u597d\u7406\u89e3\uff0c\u518d\u9032\u4e00\u6b65\u5c31\u662f\u5e95\u4e0b\u9019\u4e9b\u60c5\u6cc1\n\n* Network access is suspended.\n\n* The system ignores [wake locks](https:\/\/developer.android.com\/reference\/android\/os\/PowerManager.WakeLock.html).\n\n* Standard `[AlarmManager](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html)` alarms (including `[setExact()](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html#setExact(int, long, android.app.PendingIntent))` and `[setWindow()](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html#setWindow(int, long, long, android.app.PendingIntent))`) are deferred to the next maintenance window.\n\n* \n\n  * If you need to set alarms that fire while in Doze, use `[setAndAllowWhileIdle()](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html#setAndAllowWhileIdle(int, long, android.app.PendingIntent))` or `[setExactAndAllowWhileIdle()](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html#setExactAndAllowWhileIdle(int, long, android.app.PendingIntent))`.\n\n  * Alarms set with `[setAlarmClock()](https:\/\/developer.android.com\/reference\/android\/app\/AlarmManager.html#setAlarmClock(android.app.AlarmManager.AlarmClockInfo, android.app.PendingIntent))` continue to fire normally \u2014 the system exits Doze shortly before those alarms fire.\n\n* The system does not perform Wi-Fi scans.\n\n* The system does not allow [sync adapters](https:\/\/developer.android.com\/reference\/android\/content\/AbstractThreadedSyncAdapter.html) to run.\n\n* The system does not allow `[JobScheduler](https:\/\/developer.android.com\/reference\/android\/app\/job\/JobScheduler.html)` to run\n\n\u7e3d\u7d50\uff1a\u4e00\u53e5\u8a71\u300e\u5c31\u7b97\u662f\u79fb\u52d5\u4e2d\uff0c\u6c92\u5728\u7528\u624b\u6a5f\u6211\u4e00\u6a23\u9032\u5165\u4f11\u7720\u6a21\u5f0f\u300f\uff0c\u9019\u88e1 google \u6709\u63d0\u4f9b\u5efa\u8b70 \u300e[Using GCM to Interact with Your App While the Device is Idle](https:\/\/developer.android.com\/training\/monitoring-device-state\/doze-standby.html#using_gcm)\uff08we strongly recommend that you **use GCM if possible**, rather than maintaining your own persistent network connection.\uff09\u300f\uff0c\u5c0d\u65bc GCM \u7684\u901a\u77e5\uff0cAndroid \u6703\u6709\u7cfb\u7d71\u7d1a\u7684\u5c0d\u61c9\uff0c\u76f8\u5c0d\u597d\u5f88\u591a\u3002\n\n\u00a0\n\n#### [Project Svelte: Background Optimizations\u00a0\u5c08\u6848 Svelte\uff1a\u80cc\u666f\u6700\u4f73\u5316](https:\/\/developer.android.com\/topic\/performance\/background-optimization.html)\n\n\u5c08\u6848 Svelte \u4e00\u76f4\u52aa\u529b\u5728\u751f\u614b\u7cfb\u7d71\u4e2d\u8b93\u5404\u7a2e Android \u88dd\u7f6e\u4e0a\u7cfb\u7d71\u8207\u61c9\u7528\u7a0b\u5f0f\u4f7f\u7528\u6700\u5c11\u7684 RAM\u3002\u5728 Android N \u4e2d\uff0c\u300c\u5c08\u6848 Svelte\u300d\u5c08\u6ce8\u65bc\u6700\u4f73\u5316\u61c9\u7528\u7a0b\u5f0f\u5728\u80cc\u666f\u57f7\u884c\u7684\u65b9\u5f0f\u3002\n\n\u4e0a\u9762\u5c31\u662f\u4e00\u6bb5\u5ee2\u8a71\uff0c\u91cd\u9ede\u5c31\u662f\u00a0Android 7.0 we[\u2018](https:\/\/developer.android.com\/reference\/android\/hardware\/Camera.html)re removing three commonly-used implicit broadcasts \u2014\u00a0[CONNECTIVITY_ACTION](https:\/\/developer.android.com\/reference\/android\/net\/ConnectivityManager.html),\u00a0[ACTION_NEW_PICTURE](https:\/\/developer.android.com\/reference\/android\/hardware\/Camera.html), and [ACTION_NEW_VIDEO](https:\/\/developer.android.com\/reference\/android\/hardware\/Camera.html)\u2014 since those can wake the background processes of multiple apps at once and strain memory and battery. If your app is receiving these, take advantage of the Android 7.0 to migrate to\u00a0**JobScheduler**\u00a0and related APIs instead.\n\n\u7e3d\u7d50:\u300e\u5f9e Android 5.0\uff0c\u6211\u5c31\u4e00\u76f4\u62dc\u8a17\u5927\u5bb6\u5feb\u4f7f\u7528 **JobScheduler\uff0c\u53ef\u662f\u4f60\u5011\u597d\u50cf\u53c8\u4e0d\u592a\u611b\u7528\uff0c\u662f\u4e0d\u662f\u505a\u7684\u4e0d\u597d\u963f\uff1f\u90a3\u6211\u9019\u6b21\u4e0b\u5927\u62db\u4e86\u300fgoogle \u5982\u662f\u8aaa\u3002**\n\n\u5176\u5be6\u5c31\u662f\u9019\u4e09\u7a2e action \u90fd\u6709\u300ethundering herd\uff08\u9a5a\u7fa4\uff09\u300f\u7684\u554f\u984c\uff0c\u6703\u9020\u6210 action \u767c\u51fa\u53bb\u7684\u90a3\u4e00\u77ac\u9593\uff0c\u4e00\u5927\u5806 service \u90fd\u9192\u4f86\uff0c\u8b93 device \u8b8a\u5f97\u8017\u96fb\uff0c\u4e14\u6d6a\u8cbb\u8cc7\u6e90\uff0c\u6240\u4ee5\u9019\u6b21\u914d\u5408\u4e0a\u4e00\u6bb5 Doze \u4f86\u6539\u5584\u9019\u554f\u984c\u3002[CONNECTIVITY_ACTION](https:\/\/developer.android.com\/reference\/android\/net\/ConnectivityManager.html)\uff0c\u5728\u57f7\u884c\u4e2d\u7684AP\u9084\u662f\u53ef\u4ee5\u7528[BroadcastReceiver](https:\/\/developer.android.com\/reference\/android\/content\/BroadcastReceiver.html)\u5411 [Context.registerReceiver()](https:\/\/developer.android.com\/reference\/android\/content\/Context.html)\u8a3b\u518a\u53bb\u807d CONNECTIVITY_CHANGE\u3002\n\n#### \n\n#### [Data Saver](https:\/\/www.youtube.com\/watch?v=H-9xKmuwawg)\n\n```mermaid\nflowchart TD\n    DataSaver[Data Saver \u6d41\u91cf\u7bc0\u7701\u6a21\u5f0f] --&gt; CheckStatus{App \u662f\u5426\u5728\u524d\u666f?}\n    CheckStatus -- \u662f --&gt; Allow[\u5141\u8a31\u4e0d\u53d7\u9650\u4f7f\u7528\u884c\u52d5\u7db2\u8def]\n    CheckStatus -- \u5426 --&gt; CheckWhite{\u662f\u5426\u5728\u7cfb\u7d71\u767d\u540d\u55ae\u5167?}\n    CheckWhite -- \u662f --&gt; Allow\n    CheckWhite -- \u5426 --&gt; Block[\u6514\u622a\u80cc\u666f\u9023\u7dda\uff0c\u63a8\u9072\u975e\u7dca\u6025\u8cc7\u6599\u50b3\u8f38]<\/code><\/pre>\n<ul>\n<li>\n<p>Android 7.0 introduces Data Saver mode, a new system service that helps reduce cellular data use by apps. Data Saver gives users control over how apps use cellular data and lets developers provide more efficient service when Data Saver is on.<\/p>\n<\/li>\n<li>\n<p>When Data Saver is on, the system blocks background data usage and signals apps to use less data in the foreground wherever possible \u2014 such as by limiting bit rate for streaming, reducing image quality, deferring optimistic precaching, and so on.<\/p>\n<\/li>\n<li>\n<p>Android N \u64f4\u5145 <code>[ConnectivityManager](https:\/\/developer.android.com\/reference\/android\/net\/ConnectivityManager.html)<\/code> \u70ba\u61c9\u7528\u7a0b\u5f0f\u63d0\u4f9b<a href=\"https:\/\/developer.android.com\/preview\/features\/data-saver.html#status\">\u64f7\u53d6\u4f7f\u7528\u8005\u7684 Data Saver \u559c\u597d\u8a2d\u5b9a<\/a>\u8207<a href=\"https:\/\/developer.android.com\/preview\/features\/data-saver.html#monitor-changes\">\u76e3\u8996\u559c\u597d\u8a2d\u5b9a\u8b8a\u66f4<\/a>\u7684\u65b9\u6cd5\u3002\u6240\u6709\u61c9\u7528\u7a0b\u5f0f\u61c9\u8a72\u6aa2\u8996\u4f7f\u7528\u8005\u662f\u5426\u5df2\u555f\u7528 Data Saver \u4e26\u52aa\u529b\u9650\u5236\u524d\u666f\u8207\u80cc\u666f\u7684\u6578\u64da\u4f7f\u7528\u91cf\uff08\u671f\u8a31\u963f\uff0c\u5e0c\u671b\u5927\u5bb6\u80fd\u52a0\u5165\u4ee5\u4e0b code\uff09\u3002<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-type\">ConnectivityManager<\/span> <span class=\"hljs-variable\">connMgr<\/span> <span class=\"hljs-operator\">=<\/span> (ConnectivityManager)\n        getSystemService(Context.CONNECTIVITY_SERVICE);\n<span class=\"hljs-comment\">\/\/ Checks if the device is on a metered network<\/span>\n<span class=\"hljs-keyword\">if<\/span> (connMgr.isActiveNetworkMetered()) {\n  <span class=\"hljs-comment\">\/\/ Checks user\u2019s Data Saver settings.<\/span>\n  <span class=\"hljs-keyword\">switch<\/span> (connMgr.getRestrictBackgroundStatus()) {\n    <span class=\"hljs-keyword\">case<\/span> RESTRICT_BACKGROUND_STATUS_ENABLED:\n    <span class=\"hljs-comment\">\/\/ Background data usage is blocked for this app. Wherever possible,<\/span>\n    <span class=\"hljs-comment\">\/\/ the app should also use less data in the foreground.<\/span>\n\n    <span class=\"hljs-keyword\">case<\/span> RESTRICT_BACKGROUND_STATUS_WHITELISTED:\n    <span class=\"hljs-comment\">\/\/ The app is whitelisted. Wherever possible,<\/span>\n    <span class=\"hljs-comment\">\/\/ the app should use less data in the foreground and background.<\/span>\n\n    <span class=\"hljs-keyword\">case<\/span> RESTRICT_BACKGROUND_STATUS_DISABLED:\n    <span class=\"hljs-comment\">\/\/ Data Saver is disabled. Since the device is connected to a<\/span>\n    <span class=\"hljs-comment\">\/\/ metered network, the app should use less data wherever possible.<\/span>\n  }\n} <span class=\"hljs-keyword\">else<\/span> {\n  <span class=\"hljs-comment\">\/\/ The device is not on a metered network.<\/span>\n  <span class=\"hljs-comment\">\/\/ Use data as required to perform syncs, downloads, and updates.<\/span>\n}<\/code><\/pre>\n<p>Data saver \u5c0d\u65bc app \u7684\u8655\u7406\u6d41\u7a0b<\/p>\n<pre><code class=\"hljs language-plaintext\">flowchart TD\n    DataSaver[Data Saver \u6d41\u91cf\u7bc0\u7701\u6a21\u5f0f] --&gt; CheckStatus{App \u662f\u5426\u5728\u524d\u666f?}\n    CheckStatus -- \u662f --&gt; Allow[\u5141\u8a31\u4e0d\u53d7\u9650\u4f7f\u7528\u884c\u52d5\u7db2\u8def]\n    CheckStatus -- \u5426 --&gt; CheckWhite{\u662f\u5426\u5728\u7cfb\u7d71\u767d\u540d\u55ae\u5167?}\n    CheckWhite -- \u662f --&gt; Allow\n    CheckWhite -- \u5426 --&gt; Block[\u6514\u622a\u80cc\u666f\u9023\u7dda\uff0c\u63a8\u9072\u975e\u7dca\u6025\u8cc7\u6599\u50b3\u8f38]<\/code><\/pre>\n<p>\u7e3d\u7d50\uff1a\u770b\u5b8c<a href=\"https:\/\/www.youtube.com\/watch?v=H-9xKmuwawg\">i\/o \u4ecb\u7d39\u5f71\u7247<\/a>\u4e4b\u5f8c\uff0c\u53c8\u662f\u4e00\u500b\u62dc\u8a17\u5404\u4f4d\u7528 JobSchedule \u7684\u7cfb\u7d71\u7d1a\u9650\u5236\uff08\u90a3\u5973\u8b1b\u8005\u8868\u60c5\u8d85\u6709\u8da3\uff09\u3002\u904e\u53bb\u5c0d\u65bc Data usage \u8a2d\u5b9a\u6700\u591a\u53ea\u6709\u91dd\u5c0d\u500b\u5225 App \u7684 cellular networks \u958b\u555f\u6216\u95dc\u9589\u3002\u5982\u679c\u6709\u597d\u5fc3\u7684 App (Google \u81ea\u5bb6 Youtube\u5982\u4e0b)\uff0c\u4e86\u4e0d\u8d77\u5728\u5e95\u4e0b\u52a0\u500b APP SETTINGS \u8b93\u4f60\u958b\u555f activity \u9032\u884c\u6d41\u91cf\u9650\u5236\u8a2d\u5b9a\u3002<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- \u900f\u904e Intent \u958b\u555f\u7cfb\u7d71\u8cc7\u6599\u6d41\u91cf\u7bc0\u7701\u8a2d\u5b9a\u9801\u9762 --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">intent-filter<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">action<\/span> <span class=\"hljs-attr\">android:name<\/span>=<span class=\"hljs-string\">&quot;android.settings.MANAGE_NETWORK_USAGE&quot;<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">category<\/span> <span class=\"hljs-attr\">android:name<\/span>=<span class=\"hljs-string\">&quot;android.intent.category.DEFAULT&quot;<\/span> \/&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">intent-filter<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u5982\u679c\u662f\u61f6\u5f97\u505a\u7684 APP(Facebook \u5920\u5927\u5ee0\u4e86\u5427)\uff0c\u5565\u9b3c\u8a2d\u5b9a\u90fd\u6c92\u6709\u3002<\/p>\n<h4><\/h4>\n<h4><a href=\"https:\/\/developer.android.com\/reference\/android\/service\/quicksettings\/Tile.html\">Quick Settings Tile API\u00a0\u5feb\u901f\u8a2d\u5b9a\u78da API<\/a><\/h4>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-comment\">\/\/ Quick Settings TileService API 24+<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">MyQuickTileService<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title class_\">TileService<\/span> {\n    <span class=\"hljs-meta\">@Override<\/span>\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">onClick<\/span><span class=\"hljs-params\">()<\/span> {\n        <span class=\"hljs-type\">Tile<\/span> <span class=\"hljs-variable\">tile<\/span> <span class=\"hljs-operator\">=<\/span> getQsTile();\n        <span class=\"hljs-type\">boolean<\/span> <span class=\"hljs-variable\">isActive<\/span> <span class=\"hljs-operator\">=<\/span> (tile.getState() == Tile.STATE_ACTIVE);\n        tile.setState(isActive ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE);\n        tile.updateTile();\n    }\n}<\/code><\/pre>\n<p>\u5feb\u901f\u8a2d\u5b9a\u662f\u76f4\u63a5\u5f9e\u901a\u77e5\u6b04\u986f\u793a\u95dc\u9375\u8a2d\u5b9a\u8207\u52d5\u4f5c\u7684\u5e38\u7528\u7c21\u55ae\u65b9\u5f0f\u3002\u5728 Android N \u4e2d\uff0c\u6211\u5011\u64f4\u5145\u4e86\u5feb\u901f\u8a2d\u5b9a\u7684\u7bc4\u570d\uff0c\u8b93\u5b83\u8b8a\u5f97\u66f4\u5be6\u7528\u3001\u66f4\u4fbf\u5229\u3002<\/p>\n<p>\u6211\u5011\u4e5f\u70ba\u984d\u5916\u7684\u5feb\u901f\u8a2d\u5b9a\u78da\u589e\u52a0\u4e86\u66f4\u591a\u7a7a\u9593\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u900f\u904e\u5411\u5de6\u6216\u5411\u53f3\u64a5\u52d5\u5b58\u53d6\u5206\u9801\u986f\u793a\u5340\u57df\u3002\u6211\u5011\u4e5f\u8b93\u4f7f\u7528\u8005\u80fd\u5920\u63a7\u5236\u8981\u986f\u793a\u7684\u5feb\u901f\u8a2d\u5b9a\u78da\u8207\u986f\u793a\u4f4d\u7f6e \u2014 \u4f7f\u7528\u8005\u53ea\u9700\u62d6\u653e\u78da\uff0c\u5373\u53ef\u65b0\u589e\u6216\u79fb\u9664\u5b83\u5011\u3002<\/p>\n<p>\u5c0d\u65bc\u958b\u767c\u4eba\u54e1\uff0cAndroid N \u4e5f\u52a0\u5165\u4e86\u65b0\u7684 API\uff0c\u8b93\u60a8\u5b9a\u7fa9\u81ea\u5df1\u7684\u5feb\u901f\u8a2d\u5b9a\u78da\uff0c\u4ee5\u4fbf\u4f7f\u7528\u8005\u8f15\u9b06\u5b58\u53d6\u60a8\u61c9\u7528\u7a0b\u5f0f\u4e2d\u7684\u95dc\u9375\u63a7\u5236\u9805\u8207\u52d5\u4f5c\u3002<\/p>\n<p>\u5feb\u901f\u8a2d\u5b9a\u78da\u662f\u5c08\u70ba\u6025\u9700\u6216\u5e38\u7528\u7684\u63a7\u5236\u9805\u6216\u52d5\u4f5c\u800c\u4fdd\u7559\u7684\uff0c\u5b83\u4e0d\u61c9\u8a72\u505a\u70ba\u555f\u52d5\u61c9\u7528\u7a0b\u5f0f\u7684\u6377\u5f91\u3002<\/p>\n<p>\u5b9a\u7fa9\u78da\u4e4b\u5f8c\uff0c\u60a8\u5373\u53ef\u5c07\u5b83\u5011\u986f\u793a\u7d66\u4f7f\u7528\u8005\uff0c\u4f7f\u7528\u8005\u53ea\u9700\u62d6\u653e\u9019\u4e9b\u78da\uff0c\u5373\u53ef\u5c07\u5b83\u5011\u65b0\u589e\u5230\u5feb\u901f\u8a2d\u5b9a\u4e2d\u3002<\/p>\n<p>\u5982\u9700\u5efa\u7acb\u61c9\u7528\u7a0b\u5f0f\u78da\u7684\u76f8\u95dc\u8cc7\u8a0a\uff0c\u8acb\u53c3\u95b1\u53ef\u4e0b\u8f09\u4e4b <a href=\"https:\/\/developer.android.com\/reference\/android\/service\/quicksettings\/package-summary.html\">API \u53c3\u8003\u8cc7\u6599<\/a>\u4e2d\u7684<code>android.service.quicksettings.Tile<\/code>\u3002<\/p>\n<p>\u7e3d\u7d50\uff1a<a href=\"https:\/\/www.youtube.com\/watch?v=vTwJNlKXuMI\">\u76f4\u63a5\u770b\u5f71\u7247\u6700\u6e05\u695a<\/a><\/p>\n<p>\u8001\u5be6\u8aaa\u9019\u6771\u897f\u6211\u958b\u767c\u4e0a\u4e5f\u6c92\u6709\u7279\u5225\u73a9\u904e\uff0c\u4e4b\u524d\u90fd\u8981\u662f\u88dd\u7f6e\u958b\u767c\u5546\u624d\u80fd\u7528\uff0c\u73fe\u5728\u7d42\u65bc\u91cb\u653e\u51fa\u4f86\u7d66\u4e00\u822cAPP \u958b\u767c\u8005\u73a9 \uff08\u9019\u6a23\u771f\u7684\u90e8\u6703\u51fa\u73fe\u4e00\u5927\u5806\u5728 setting bar \u4e0a\u9762\u55ce\uff1f\u4e4b\u5f8c\u53ef\u4ee5\u5be6\u9a57\uff0c\u4e00\u96bb app \u5230\u5e95\u53ef\u4ee5\u653e\u5e7e\u500b tile\u4e0a\u53bb\u3002\u4e3b\u8981\u505a\u6cd5\u9808\u8981\u5be6\u4f5c TileService \u53bb\u807d change \u4e14\u6709 permission \u201candroid.permission.BIND_QUICK_SETTINGS_TILE\u201d\uff09\u3002\uff08ps. \u6709\u6a5f\u6703\u7684\u8a71\uff0c\u8acb\u6211\u7684\u597d\u540c\u4e8b J\u5927\u4f86\u8ac7\u4e00\u4e0b\u9019\u7ae0\u7bc0\uff0c\u4f86\u8ac7\u8ac7 api 24 \u4e4b\u524d\u7684 quick settings \u958b\u767c\u8f9b\u9178\u53f2\uff0c\u807d\u4ed6\u8f49\u8ff0\u611f\u89ba google \u5c31\u662f\u5728\u505a\u4ed6\u4e4b\u524d\u7684\u4e8b\u60c5\u554a\uff09<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-comment\">\/\/ Quick Settings TileService API 24+<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">MyQuickTileService<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title class_\">TileService<\/span> {\n    <span class=\"hljs-meta\">@Override<\/span>\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">onClick<\/span><span class=\"hljs-params\">()<\/span> {\n        <span class=\"hljs-type\">Tile<\/span> <span class=\"hljs-variable\">tile<\/span> <span class=\"hljs-operator\">=<\/span> getQsTile();\n        <span class=\"hljs-type\">boolean<\/span> <span class=\"hljs-variable\">isActive<\/span> <span class=\"hljs-operator\">=<\/span> (tile.getState() == Tile.STATE_ACTIVE);\n        tile.setState(isActive ? Tile.STATE_INACTIVE : Tile.STATE_ACTIVE);\n        tile.updateTile();\n    }\n}<\/code><\/pre>\n<p>\u00a0<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/training\/tv\/tif\/content-recording.html\">Android TV \u9304\u88fd<\/a><\/h4>\n<pre><code class=\"hljs language-plaintext\">[Android TV TIF (TvInputFramework) \u9304\u88fd\u67b6\u69cb]\nTvInputService -&gt; TvRecordingClient -&gt; \u4e32\u6d41\u9304\u88fd -&gt; \u79c1\u6709\u76ee\u9304\u6c99\u76d2\u5132\u5b58<\/code><\/pre>\n<p>Android N \u900f\u904e\u65b0\u7684\u9304\u88fd API\uff0c\u65b0\u589e\u4e86\u9304\u88fd\u548c\u64ad\u653e Android TV \u8f38\u5165\u670d\u52d9\u5167\u5bb9\u7684\u529f\u80fd\u3002\u4ee5\u73fe\u6709\u7684\u6642\u9593\u4f4d\u79fb API \u70ba\u5efa\u7f6e\u57fa\u790e\uff0cTV \u8f38\u5165\u670d\u52d9\u53ef\u4ee5\u63a7\u5236\u8981\u9304\u88fd\u54ea\u500b\u983b\u9053\u7684\u8cc7\u6599\u3001\u5982\u4f55\u5132\u5b58\u5df2\u9304\u88fd\u7684\u6642\u6bb5\uff0c\u4ee5\u53ca\u7ba1\u7406\u4f7f\u7528\u8005\u8207\u9304\u88fd\u5167\u5bb9\u7684\u4e92\u52d5\u3002<\/p>\n<p>\u5982\u9700\u8a73\u7d30\u8cc7\u8a0a\uff0c\u8acb\u53c3\u95b1 <a href=\"https:\/\/developer.android.com\/preview\/features\/tv-recording-api.html\">Android TV \u9304\u88fd API<\/a>\u3002<\/p>\n<p>\u7e3d\u7d50\uff1a\u6c92\u7528\u904e\u4e5f\u6c92\u73a9\u904e\uff0c\u4f46\u611f\u89ba\u5f88\u65b9\u4fbf\u3002\u6b61\u8fce\u5927\u5bb6\u63d0\u4f9b\u770b\u6cd5\u3002<\/p>\n<p>\u00a0<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/training\/articles\/security-config.html\">Network Security Configuration\u00a0\u7db2\u8def\u5b89\u5168\u6027\u5f37\u5316<\/a><\/h4>\n<p>\u8def\u5b89\u5168\u6027\u8a2d\u5b9a\u529f\u80fd\uff0c\u8b93\u61c9\u7528\u7a0b\u5f0f\u5728\u5b89\u5168\u7684\u5ba3\u544a\u5f0f\u8a2d\u5b9a\u6a94\u4e2d\u5373\u53ef\u81ea\u8a02\u7db2\u8def\u5b89\u5168\u6027\u8a2d\u5b9a\uff0c\u800c\u4e0d\u5fc5\u4fee\u6539\u61c9\u7528\u7a0b\u5f0f\u7684\u7a0b\u5f0f\u78bc\u3002 \u9019\u4e9b\u8a2d\u5b9a\u53ef\u4ee5\u91dd\u5c0d\u7279\u5b9a\u7db2\u57df\u4ee5\u53ca\u91dd\u5c0d\u7279\u5b9a\u61c9\u7528\u7a0b\u5f0f\u4f86\u8a2d\u5b9a\u3002\u4e3b\u8981\u6709\u4ee5\u4e0b\u56db\u9ede\u3002<\/p>\n<p>\u9019\u4e00\u6bb5\u771f\u7684\u6bd4\u8f03\u662f\u5c6c\u65bc\u958b\u767c\u5c64\u9762\uff0c\u76ee\u524d\u9084\u662f\u6bd4\u8f03\u5c11\u78b0\u4e00\u584a\uff0c\u5e0c\u671b\u6211\u7684\u7406\u89e3\u662f\u5c0d\u5f97\uff0c\u4e5f\u6b61\u8fce\u5404\u4f4d\u6307\u6559<\/p>\n<p>**1. Custom trust anchors:**Customize which Certificate Authorities (CA) are trusted for an app\u2019s secure connections. For example, trusting particular self-signed certificates or restricting the set of public CAs that the app trusts.<\/p>\n<p>\u8a2d\u5b9a\u81ea\u6191\u8b49 \uff06\u00a0\u9650\u6b62\u4fe1\u4efb\u7684 CA \u7d44<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- res\/xml\/network_security_config.xml --&gt;<\/span>\n<span class=\"hljs-comment\">&lt;!-- \u81ea\u8a02\u4fe1\u4efb\u9328\u9ede\u8207\u9650\u5236\u4fe1\u4efb\u7684 CA \u7d44 --&gt;<\/span>\n<span class=\"hljs-meta\">&lt;?xml version=<span class=\"hljs-string\">&quot;1.0&quot;<\/span> encoding=<span class=\"hljs-string\">&quot;utf-8&quot;<\/span>?&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">base-config<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">certificates<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">&quot;system&quot;<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">base-config<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u4fe1\u4efb\u5176\u4ed6 CA<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- \u4fe1\u4efb\u81ea\u8a02 CA (\u4f8b\u5982\u5167\u90e8\u4f3a\u670d\u5668\u79c1\u6709\u6191\u8b49) --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain-config<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain<\/span> <span class=\"hljs-attr\">includeSubdomains<\/span>=<span class=\"hljs-string\">&quot;true&quot;<\/span>&gt;<\/span>internal.example.com<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">certificates<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">&quot;@raw\/my_ca&quot;<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain-config<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span><\/code><\/pre>\n<p>**\u81ea\u8a02\u4fe1\u4efb\u9328\u9ede:\u00a0**\u5176\u5be6\u53ea\u770b\u4e0a\u9762\u7684 xml code \uff0c\u500b\u4eba\u5f88\u76f4\u89ba\u5f97\u5c31\u662f\u628a\u4ee5\u524d\u5c0d ssl(Secure Sockets Layer) \u7684\u8655\u7406\u7531\u7a0b\u5f0f\u78bc\u8f49\u63db\u5230 google xml \u7684\u898f\u7bc4\u5316\uff0c\u9019\u78ba\u5be6\u53ef\u4ee5\u6709\u6548\u964d\u4f4e\u958b\u767c\u8005\u7684\u82e6\u5de5\u3002\u4ee5\u524d\u7684\u73a9\u6cd5\u5c31\u662f\u5728 Android \u88e1\u4f7f\u7528 HttpUrlConnection \u4f7f\u7528 TrustManager \u53bb\u8655\u7406\u3002\u4e8b\u5be6\u4e0a\u5927\u90e8\u5206\u958b\u767c\u4e0b\u4e0d\u5c11\u958b\u767c\u8005\u662f\u4e0d\u592a\u8655\u7406\u9019\u584a\uff0c\u4e3b\u8981\u662f\u56e0\u70ba Android \u5df2\u7d93\u9810\u5148\u628a\u5408\u6cd5\u767c\u884c\u55ae\u4f4d\uff08VeriSign\uff09\u7684\u6191\u8b49\u90fd\u62c9\u9032\u4f86\u3002\u800c\u6bd4\u8f03\u7279\u6b8a\u7684\u60c5\u6cc1\u5247\u662f\u958b\u767c\u8005\u81ea\u5df1\u9700\u8981\u9023\u7dda\u5230\u81ea\u5df1\u7684 server \u4f5c\u5b58\u53d6\uff0c\u7136\u5f8c\u53c8\u4e0d\u60f3\u4f7f\u7528\u767c\u884c\u55ae\u4f4d\u767c\u884c\u7684\u6191\u8b49\uff0c\u539f\u56e0\u5176\u5be6\u883b\u7c21\u55ae\uff0c\u5c31\u662f\u9001\u53bb\u767c\u884c\u55ae\u4f4d\u4e00\u5e74\u5927\u6982\u8981\u7e73\u8cbb 100 \u2013 500 \u7f8e\u91d1\uff0c\u4e14\u5927\u90e8\u5206 app \u6703\u5b58\u53d6\u7684 server \u90fd\u883b\u56fa\u5b9a\uff08\u80a1\u7968:\u901a\u5e38\u6703\u8981\u6c42\u4f7f\u7528\u500b\u4eba CA\uff0c\u4fe1\u4ef6:\u901a\u5e38\u6703\u81ea\u5df1 Import \u516c\u53f8\u7684 CA\u2026.\uff09\u3002<\/p>\n<p>\u4ee5\u4e0b\u70ba\u904e\u53bb\u7684\u5beb\u6cd5\uff0c\u70ba\u4e86\u8655\u7406\u81ea\u767c\u884c\u6191\u8b49\uff0c\u4e0d\u5c11 google c\/p\uff08\u5c31\u662f\u6211\uff09 \u5de5\u7a0b\u5e2b\u5c31\u6703\u72af\u4e00\u4e9b\u932f\u8aa4\uff0c\u7b2c\u4e00\u6bb5\u7a0b\u5f0f\u78bc\u6703\u4fe1\u4efb\u6240\u6709\u7684 CA \uff0c\u9019\u6a23\u641e\u7684\u8a71\u6709 SSL \u8ddf\u6c92 SSL \u662f\u4e00\u6a23\u7684\u3002<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-keyword\">import<\/span> org.apache.http.conn.ssl.SSLSocketFactory;\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">MySSLSocketFactory<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title class_\">SSLSocketFactory<\/span> {\n    <span class=\"hljs-type\">SSLContext<\/span> <span class=\"hljs-variable\">sslContext<\/span> <span class=\"hljs-operator\">=<\/span> SSLContext.getInstance(<span class=\"hljs-string\">&quot;TLS&quot;<\/span>);\n \n    <span class=\"hljs-type\">public<\/span> <span class=\"hljs-title function_\">MySSLSocketFactory<\/span><span class=\"hljs-params\">(KeyStore truststore)<\/span> <span class=\"hljs-keyword\">throws<\/span> NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {\n        <span class=\"hljs-built_in\">super<\/span>(truststore);\n \n        <span class=\"hljs-type\">TrustManager<\/span> <span class=\"hljs-variable\">tm<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">X509TrustManager<\/span>() {\n            <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">checkClientTrusted<\/span><span class=\"hljs-params\">(X509Certificate[] chain, String authType)<\/span> <span class=\"hljs-keyword\">throws<\/span> CertificateException {\n            }\n \n            <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">checkServerTrusted<\/span><span class=\"hljs-params\">(X509Certificate[] chain, String authType)<\/span> <span class=\"hljs-keyword\">throws<\/span> CertificateException {\n            }\n \n            <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">X509Certificate<\/span>[] <span class=\"hljs-title function_\">getAcceptedIssuers<\/span><span class=\"hljs-params\">()<\/span> {\n                <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">null<\/span>;\n            }\n        };\n \n        sslContext.init(<span class=\"hljs-literal\">null<\/span>, <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">TrustManager<\/span>[] { tm }, <span class=\"hljs-literal\">null<\/span>);\n   }\n \n    <span class=\"hljs-meta\">@Override<\/span>\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">Socket<\/span> <span class=\"hljs-title function_\">createSocket<\/span><span class=\"hljs-params\">(Socket socket, String host, <span class=\"hljs-type\">int<\/span> port, <span class=\"hljs-type\">boolean<\/span> autoClose)<\/span> <span class=\"hljs-keyword\">throws<\/span> IOException, UnknownHostException {\n        <span class=\"hljs-keyword\">return<\/span> sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);\n    }\n \n    <span class=\"hljs-meta\">@Override<\/span>\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">Socket<\/span> <span class=\"hljs-title function_\">createSocket<\/span><span class=\"hljs-params\">()<\/span> <span class=\"hljs-keyword\">throws<\/span> IOException {\n        <span class=\"hljs-keyword\">return<\/span> sslContext.getSocketFactory().createSocket();\n    }\n}<\/code><\/pre>\n<p>\u800c\u4ee5\u4e0b\u9019\u6bb5\u5247\u662f \u8cb7\u4e00\u5957\u9001\u5168\u90e8\u7684\u5178\u578b\u7bc4\u4f8b\uff0c\u7576\u6191\u8b49\u63a5\u53d7\u5176\u4e2d\u4e00\u500b\u7db2\u7ad9\u7684 server \uff0c\u90a3\u9ebc\u5176\u4ed6\u7684\u4e5f\u7d71\u7d71\u90fd\u63a5\u53d7\u4e86<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-type\">HostnameVerifier<\/span> <span class=\"hljs-variable\">hostnameVerifier<\/span> <span class=\"hljs-operator\">=<\/span> org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;\n \n<span class=\"hljs-type\">DefaultHttpClient<\/span> <span class=\"hljs-variable\">client<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">DefaultHttpClient<\/span>();\n \n<span class=\"hljs-type\">SchemeRegistry<\/span> <span class=\"hljs-variable\">registry<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">SchemeRegistry<\/span>();\n<span class=\"hljs-type\">SSLSocketFactory<\/span> <span class=\"hljs-variable\">socketFactory<\/span> <span class=\"hljs-operator\">=<\/span> SSLSocketFactory.getSocketFactory();\nsocketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);\nregistry.register(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">Scheme<\/span>(<span class=\"hljs-string\">&quot;https&quot;<\/span>, socketFactory, <span class=\"hljs-number\">443<\/span>));\n<span class=\"hljs-type\">SingleClientConnManager<\/span> <span class=\"hljs-variable\">mgr<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">SingleClientConnManager<\/span>(client.getParams(), registry);\n<span class=\"hljs-type\">DefaultHttpClient<\/span> <span class=\"hljs-variable\">httpClient<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">DefaultHttpClient<\/span>(mgr, client.getParams());\n \n<span class=\"hljs-comment\">\/\/ Set verifier     <\/span>\nHttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);\n \n<span class=\"hljs-comment\">\/\/ Example send http request<\/span>\n<span class=\"hljs-keyword\">final<\/span> <span class=\"hljs-type\">String<\/span> <span class=\"hljs-variable\">url<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">&quot;https:\/\/www.pchome.com\u201d\nHttpPost httpPost = new HttpPost(url);\nHttpResponse response = httpClient.execute(httpPost);\n \nHttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);\n\nHostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;<\/span><\/code><\/pre>\n<p>\u626f\u7684\u9019\u908a\u6709\u9ede\u9060\u4e86\uff0c\u4e3b\u8981\u662f\u60f3\u628a\u524d\u56e0\u5f8c\u679c\u9084\u6709\u800d\u7b28\u7684\u6545\u4e8b\u5beb\u4e00\u4e0b\u3002\u53e6\u5916\u4e0d\u77e5\u9053\u6709\u6c92\u6709\u4eba\u89ba\u5f97 raw\/my_ca \u9019\u6a23\u5beb\u6703\u6709\u554f\u984c\uff0c\u5982\u679c\u88ab\u53cd\u7d44\u8b6f\uff0c\u90a3\u9019\u500b CA \u6191\u8b49\u4e0d\u662f\u5f88\u5371\u96aa\u55ce\uff1f\u6839\u64da\u5c0f\u7d44\u8a0e\u8ad6\uff0c\u611f\u89ba\u9019\u500b ca \u61c9\u8a72\u55ae\u7d14\u53ea\u662f\u500b\u516c\u9470\uff0c\u6216\u662f\u53ea\u662f\u55ae\u7d14\u70ba\u4e86\u7bc4\u4f8b\u7c21\u55ae\u5beb\u800c\u5df2\u00a0 \uff0c\u6b61\u8fce\u6709\u9ad8\u624b\u5e6b\u5fd9\u89e3\u7b54\u3002<\/p>\n<p>**2. Debug-only overrides:**Safely debug secure connections in an app without added risk to the installed base.<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- \u50c5\u5728 Debug Build \u4fe1\u4efb\u4f7f\u7528\u8005\u5b89\u88dd\u7684\u6e2c\u8a66\u6191\u8b49 (\u5b89\u5168\u9694\u96e2) --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">debug-overrides<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">certificates<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">&quot;user&quot;<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">trust-anchors<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">debug-overrides<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u8a2d\u5b9a CA \u9032\u884c\u5075\u932f\uff1a\u300c\u53ea\u300d\u6709\u5728 <a href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/application-element.html#debug\">android:debuggable<\/a> \u70ba <code>true<\/code> \u6642\u624d\u4e88\u4ee5\u4fe1\u4efb\u3002\u5c31\u662f\u5be6\u7528\u6e2c\u8a66\u529f\u80fd\uff0c\u53ef\u4ee5\u628a\u5728 code \u88e1\u9762\u7684 DEBUG \u642c\u51fa\u4f86\u3002\u56e0\u70ba play store\u00a0\u63a1\u53d6\u7684\u5b89\u5168\u63aa\u65bd\u662f\uff0c\u4e0d\u63a5\u53d7\u6a19\u793a\u70ba\u53ef\u5075\u932f\u7684\u61c9\u7528\u7a0b\u5f0f\uff0c\u6240\u4ee5\u9019\u7a2e\u65b9\u5f0f\u6703\u6bd4\u689d\u4ef6\u5f0f\u7a0b\u5f0f\u78bc\u5b89\u5168\u3002<\/p>\n<p><strong>3. Cleartext<\/strong>** traffic opt-out:**Protect apps from accidental usage of cleartext traffic.<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- \u9000\u51fa\u660e\u78bc\u50b3\u8f38 (Cleartext traffic opt-out) \u9632\u79a6\u6d41\u91cf\u7aca\u807d --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain-config<\/span> <span class=\"hljs-attr\">cleartextTrafficPermitted<\/span>=<span class=\"hljs-string\">&quot;false&quot;<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain<\/span> <span class=\"hljs-attr\">includeSubdomains<\/span>=<span class=\"hljs-string\">&quot;true&quot;<\/span>&gt;<\/span>secure.example.com<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain-config<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span><\/code><\/pre>\n<p><strong>\u9000\u51fa\u660e\u78bc\u6d41\u91cf<\/strong>\uff1a\u6253\u7b97\u53ea\u4f7f\u7528\u5b89\u5168\u9023\u7dda\u9023\u7dda\u81f3\u76ee\u7684\u5730\u7684\u61c9\u7528\u7a0b\u5f0f\uff0c\u53ef\u4ee5\u91dd\u5c0d\u90a3\u4e9b\u76ee\u7684\u5730\u9000\u51fa\u652f\u63f4\u660e\u78bc (\u4f7f\u7528\u672a\u52a0\u5bc6\u7684 HTTP \u901a\u8a0a\u5354\u5b9a\uff0c\u800c\u975e HTTPS)\u3002 \u6b64\u9078\u9805\u6709\u52a9\u65bc\u907f\u514d\u61c9\u7528\u7a0b\u5f0f\u7531\u65bc\u5916\u90e8\u4f86\u6e90 (\u4f8b\u5982\uff0c\u5f8c\u7aef\u4f3a\u670d\u5668) \u63d0\u4f9b\u7684 URL \u4e2d\u767c\u751f\u8b8a\u66f4\uff0c\u800c\u9020\u6210\u610f\u5916\u56de\u5fa9\u3002 \u5982\u9700\u66f4\u591a\u8a73\u7d30\u8cc7\u6599\uff0c\u8acb\u53c3\u95b1\u00a0<code>[NetworkSecurityPolicy.isCleartextTrafficPermitted()](https:\/\/developer.android.com\/reference\/android\/security\/NetworkSecurityPolicy.html?hl=km#isCleartextTrafficPermitted())<\/code>\u3002\u300e<\/p>\n<p>This flag is honored on a best effort basis because it\u2019s impossible to prevent all cleartext traffic from Android applications given the level of access provided to them. For example, there\u2019s no expectation that the <code>[Socket](https:\/\/developer.android.com\/reference\/java\/net\/Socket.html?hl=km)<\/code> API will honor this flag because it cannot determine whether its traffic is in cleartext. However, most network traffic from applications is handled by higher-level network stacks\/components which can honor this aspect of the policy.<\/p>\n<p>NOTE: <code>[WebView](https:\/\/developer.android.com\/reference\/android\/webkit\/WebView.html?hl=km)<\/code> does not honor this flag.\u300f<\/p>\n<p>\u4f8b\u5982\u4e0a\u9762\uff0c\u61c9\u7528\u7a0b\u5f0f\u60f3\u8981\u78ba\u4fdd secure.example.com \u7684\u6240\u6709\u9023\u7dda\u4e00\u5f8b\u8981\u900f\u904e HTTPS \u5b8c\u6210\uff0c\u4ee5\u4fdd\u8b77\u654f\u611f\u6d41\u91cf\u4e0d\u53d7\u60e1\u610f\u7db2\u8def\u5371\u5bb3\u3002<\/p>\n<p>\u88dc\u5145\uff1a\u5728 API level 23. \u6709\u52a0\u5165\u9019\u500b\u00a0android:usesCleartextTraffic\uff0c\u4f46\u9019\u500b\u662f\u6240\u6709\u7db2\u57df\u90fd\u88ab\u9650\u5236\u4f4f\uff0c\u9810\u8a2d\u503c\u662f true (for example, HTTP and FTP stacks, <code>[DownloadManager](https:\/\/developer.android.com\/reference\/android\/app\/DownloadManager.html)<\/code>, <code>[MediaPlayer](https:\/\/developer.android.com\/reference\/android\/media\/MediaPlayer.html)<\/code>)<\/p>\n<p>**4. Certificate pinning:**Restrict an app\u2019s secure connection to particular certificates.<\/p>\n<p>**<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- \u6191\u8b49\u95dc\u806f (Certificate Pinning) \u9632\u79a6\u4e2d\u7e7c\u4eba\u653b\u64ca (MiTM) --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain-config<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">domain<\/span> <span class=\"hljs-attr\">includeSubdomains<\/span>=<span class=\"hljs-string\">&quot;true&quot;<\/span>&gt;<\/span>api.example.com<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pin-set<\/span> <span class=\"hljs-attr\">expiration<\/span>=<span class=\"hljs-string\">&quot;2027-01-01&quot;<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pin<\/span> <span class=\"hljs-attr\">digest<\/span>=<span class=\"hljs-string\">&quot;SHA-256&quot;<\/span>&gt;<\/span>7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">pin<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">pin-set<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">domain-config<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">network-security-config<\/span>&gt;<\/span>\n```\u95dc\u806f\u6191\u8b49\uff1a**\n\n\u61c9\u7528\u7a0b\u5f0f\u4e00\u822c\u6703\u4fe1\u4efb\u6240\u6709\u9810\u5148\u5b89\u88dd\u7684 CA\u3002\u82e5\u9019\u985e\u7684\u4efb\u4f55 CA \u610f\u5728\u767c\u884c\u8a50\u9a19\u6191\u8b49\uff0c\u61c9\u7528\u7a0b\u5f0f\u6703\u6709\u906d\u53d7 MiTM \u653b\u64ca\u7684\u98a8\u96aa\u3002 \u6709\u4e9b\u61c9\u7528\u7a0b\u5f0f\u9078\u64c7\u900f\u904e\u9650\u5236\u6240\u4fe1\u4efb\u7684 CA \u7d44\u6216\u95dc\u806f\u6191\u8b49\uff0c\u4f86\u9650\u5236\u53ef\u63a5\u53d7\u7684\u6191\u8b49\u7d44\u3002\n\n\u6191\u8b49\u95dc\u806f\u7684\u65b9\u6cd5\u662f\uff0c\u900f\u904e\u516c\u7528\u91d1\u9470\u7684\u96dc\u6e4a (X.509 \u6191\u8b49\u7684 SubjectPublicKeyInfo) \u4f86\u63d0\u4f9b\u4e00\u7d44\u6191\u8b49\u3002 \u53ea\u6709\u7576\u6191\u8b49\u93c8\u81f3\u5c11\u5305\u542b\u4e00\u500b\u95dc\u806f\u7684\u516c\u7528\u91d1\u9470\u6642\uff0c\u624d\u662f\u6709\u6548\u7684\u6191\u8b49\u93c8\u3002\n\n\u8acb\u6ce8\u610f\uff0c\u4f7f\u7528\u6191\u8b49\u95dc\u806f\u6642\uff0c\u60a8\u52d9\u5fc5\u8981\u5305\u62ec\u5099\u4efd\u91d1\u9470\uff0c\u9019\u6a23\u842c\u4e00\u5f37\u5236\u60a8\u5207\u63db\u5230\u65b0\u7684\u91d1\u9470\u6216\u8b8a\u66f4 CA (\u95dc\u806f\u5230 CA \u6191\u8b49\u6216\u8a72 CA \u7684\u4e2d\u7e7c\u8005) \u6642\uff0c\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u9023\u7dda\u624d\u4e0d\u6703\u53d7\u5230\u5f71\u97ff\u3002 \u5426\u5247\uff0c\u60a8\u5fc5\u9808\u63a8\u51fa\u61c9\u7528\u7a0b\u5f0f\u66f4\u65b0\uff0c\u624d\u80fd\u9084\u539f\u9023\u7dda\u3002\n\n\u7e3d\u7d50\uff1a\u9019\u6bb5\u6211\u53ea\u6709\u5728\u958b\u767c mail \u6642\u6709\u7a0d\u5fae\u6d89\u7565\u3002\u6c92\u8fa6\u6cd5\u7d66\u51fa\u66f4\u591a\u5be6\u52d9\u4e0a\u7684\u611f\u60f3\u3002\u4f46\u770b\u5f97\u51fa\u4f86 google \u5f9e M \u958b\u59cb\u5c31\u975e\u5e38\u6ce8\u610f\uff0c\u4f46\u662f M \u6240\u5728\u610f\u7684\u5247\u662f device \u64cd\u4f5c\u4ee5\u53ca\u4f7f\u7528\u8005\u8cc7\u6599\u7684\u6b0a\u9650\u5b89\u5168\uff0c\u800c N \u5247\u662f\u66f4\u52a0\u5f37\u5316\u7db2\u8def\u5b89\u5168\u9019\u584a\u3002\u770b\u8d77\u4f86\u61c9\u8a72\u662f\u767c\u751f\u904e\u592a\u591a\u554f\u984c\u5566\u3002\n\n\u00a0\n\n#### [Scoped Directory Access\u00a0\u9650\u5b9a\u7bc4\u570d\u76ee\u9304\u5b58\u53d6](https:\/\/developer.android.com\/training\/articles\/scoped-directory-access.html)\n\n\u61c9\u7528\u7a0b\u5f0f (\u4f8b\u5982\uff0c\u76f8\u7247\u61c9\u7528\u7a0b\u5f0f) \u901a\u5e38\u53ea\u9700\u8981\u5b58\u53d6\u5916\u90e8\u5132\u5b58\u7a7a\u9593\u4e2d\u7684\u7279\u5b9a\u76ee\u9304\uff0c\u4f8b\u5982\u00a0`Pictures` \u76ee\u9304\u3002 \u76ee\u524d\u7528\u4f86\u5b58\u53d6\u5916\u90e8\u5132\u5b58\u7a7a\u9593\u7684\u65b9\u5f0f\u4e26\u975e\u8a2d\u8a08\u4f86\u8f15\u9b06\u5730\u70ba\u9019\u4e9b\u985e\u578b\u7684\u61c9\u7528\u7a0b\u5f0f\u63d0\u4f9b\u5df2\u8a2d\u5b9a\u76ee\u6a19\u7684\u76ee\u9304\u5b58\u53d6\u3002 \u4f8b\u5982\uff1a\n\n* \u5728\u60a8\u7684\u5ba3\u793a\u8aaa\u660e\u4e2d\u8981\u6c42 `[READ_EXTERNAL_STORAGE](https:\/\/developer.android.com\/reference\/android\/Manifest.permission.html#READ_EXTERNAL_STORAGE)` \u6216 `[WRITE_EXTERNAL_STORAGE](https:\/\/developer.android.com\/reference\/android\/Manifest.permission.html#WRITE_EXTERNAL_STORAGE)` \u53ef\u5141\u8a31\u5b58\u53d6\u5916\u90e8\u5132\u5b58\u7a7a\u9593ac\u4e0a\u7684\u6240\u6709\u516c\u7528\u76ee\u9304\uff0c\u4f46\u9019\u53ef\u80fd\u8d85\u904e\u60a8\u61c9\u7528\u7a0b\u5f0f\u6240\u9700\u7684\u5b58\u53d6\u6b0a\u3002\n\n* \u4f7f\u7528[\u5132\u5b58\u7a7a\u9593\u5b58\u53d6\u67b6\u69cb](https:\/\/developer.android.com\/guide\/topics\/providers\/document-provider.html)\u901a\u5e38\u6703\u4f7f\u5f97\u60a8\u7684\u4f7f\u7528\u8005\u900f\u904e\u7cfb\u7d71 UI \u6311\u9078\u76ee\u9304\uff0c\u9019\u5728\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u4e00\u5f8b\u5b58\u53d6\u76f8\u540c\u5916\u90e8\u76ee\u9304\u7684\u60c5\u6cc1\u4e0b\u662f\u4e0d\u5fc5\u8981\u7684\u3002\n\nAndroid N \u63d0\u4f9b\u65b0\u7684\u7c21\u5316 API\uff0c\u53ef\u7528\u4f86\u5b58\u53d6\u5e38\u7528\u5916\u90e8\u5132\u5b58\u7a7a\u9593\u76ee\u9304\u3002\n\n```java\n\/\/ \u958b\u555f\u4e3b\u8981\u5171\u7528\u5132\u5b58\u7a7a\u9593\u4e2d\u7684 Pictures \u76ee\u9304\nStorageManager sm = (StorageManager)getSystemService(Context.STORAGE_SERVICE);\nStorageVolume volume = sm.getPrimaryVolume();\nIntent intent = volume.createAccessIntent(Environment.DIRECTORY_PICTURES);\nstartActivityForResult(intent, request_code);<\/code><\/pre>\n<p>\u4e26\u5411\u4f7f\u7528\u8005\u78ba\u8a8d\u6b0a\u9650<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Scoped Directory Access: \u5411\u4f7f\u7528\u8005\u8acb\u6c42\u7279\u5b9a\u5916\u90e8\u76ee\u9304\u5b58\u53d6\u6b0a\u9650 --&gt;<\/span>\n<span class=\"hljs-comment\">&lt;!-- \u4ee3\u66ff\u5168\u57df READ_EXTERNAL_STORAGE\uff0c\u5be6\u73fe\u6700\u5c0f\u6b0a\u9650\u539f\u5247 --&gt;<\/span><\/code><\/pre>\n<p>\u5b58\u53d6\u5916\u90e8\u7a7a\u9593\u5247\u9700\u8981\uff0c\u53e6\u5916\u5ba3\u544a<\/p>\n<pre><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Scoped Directory Access: \u5411\u4f7f\u7528\u8005\u8acb\u6c42\u7279\u5b9a\u5916\u90e8\u76ee\u9304\u5b58\u53d6\u6b0a\u9650 --&gt;<\/span>\n<span class=\"hljs-comment\">&lt;!-- \u4ee3\u66ff\u5168\u57df READ_EXTERNAL_STORAGE\uff0c\u5be6\u73fe\u6700\u5c0f\u6b0a\u9650\u539f\u5247 --&gt;<\/span><\/code><\/pre>\n<pre><code class=\"hljs language-plaintext\">\/\/ BroadcastReceiver has already cached the MEDIA_MOUNTED\n\/\/ notification Intent in mediaMountedIntent\nStorageVolume volume = (StorageVolume)\n    mediaMountedIntent.getParcelableExtra(StorageVolume.EXTRA_STORAGE_VOLUME);\nvolume.createAccessIntent(Environment.DIRECTORY_PICTURES);\nstartActivityForResult(intent, request_code);<\/code><\/pre>\n<p>\u7e3d\u7d50\uff1a\u4e00\u76f4\u5230\u76ee\u524d\uff0c\u5e7e\u4e4e\u6240\u6709\u7684 app \u958b\u767c\u5c0d\u65bc store access \u6b0a\u9650\u90fd\u662f\u5168\u6709\u6216\u662f\u5168\u7121\uff0c\u9019\u5c0d\u4f7f\u7528\u8005\u6703\u5728\u7d66\u4e88\u6b0a\u9650\u611f\u5230\u6050\u614c\u3002google \u4e5f\u4e0d\u662f\u6c92\u6709\u60f3\u904e\u9019\u554f\u984c\uff0c\u5c31\u662f\u5728 kitkat \u6642\u52a0\u5165\u7684\u00a0<a href=\"https:\/\/developer.android.com\/guide\/topics\/providers\/document-provider.html\">Storage Access Framework<\/a> \u8b93\u4f7f\u7528\u8005\u81ea\u5df1\u6311\u9078\u8cc7\u6599\u593e\u7d66\u4e88\u5b58\u53d6\uff0c\u4f46\u8001\u5be6\u8aaa\u6211\u9084\u771f\u7684\u5f88\u5c11\u770b\u5230\u6703\u4f7f\u7528 SAF \u7684 app \uff0c\u4e3b\u8981\u9084\u662f\u56e0\u70ba\u4f7f\u7528\u8005\u6703\u89ba\u5f97\u592a\u9ebb\u7169\uff0c\u7e3d\u548c\u300e\u597d\u9ebb\u7169\u300f\u548c\u300e\u901a\u5929\u7684\u6b0a\u9650\u300f\u5169\u500b\u554f\u984c\uff0c \u5c31\u5e0c\u671b\u80fd\u53d6\u6d88\u5169\u5927\u8cc7\u6599\u5b58\u53d6\u6b0a\u9650\uff0c\u7136\u5f8c\u91dd\u5c0d\u56fa\u5b9a\u901a\u7528\u578b\u7684\u7cfb\u7d71\u8cc7\u6599\u593e\u505a\u51fa\u7c21\u5316\u64cd\u4f5c\uff0c\u6539\u6210\u767c intent \u7684\u65b9\u5f0f\u53bb\u8acb\u7cfb\u7d71\u5e6b\u5fd9\u4fdd\u8b49\u8cc7\u6599\u7684\u5b58\u53d6\u7bc4\u570d\u3002ps.\u53d6\u5f97\u5c0d\u7279\u5b9a\u5916\u90e8\u76ee\u9304\u7684\u5b58\u53d6\u6b0a\u4e5f\u6703\u53d6\u5f97\u5c0d\u8a72\u76ee\u9304\u4e4b\u5b50\u76ee\u9304\u7684\u5b58\u53d6\u6b0a\u3002<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html?hl=en\">Virtual Files \u865b\u64ec\u6a94\u6848<\/a><\/h4>\n<p>In previous versions of Android, your app could use the Storage Access Framework to allow users to select files from their cloud storage accounts, such as Google Drive. However, there was no way to represent files that did not have a direct bytecode representation; every file was required to provide an input stream.<\/p>\n<p>Android 7.0 adds the concept of <em>virtual files<\/em> to the Storage Access Framework. The virtual files feature allows your <code>[DocumentsProvider](https:\/\/developer.android.com\/reference\/android\/provider\/DocumentsProvider.html)<\/code> to return document URIs that can be used with an <code>[ACTION_VIEW](https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#ACTION_VIEW)<\/code> intent even if they don\u2019t have a direct bytecode representation. Android 7.0 also allows you to provide alternate formats for user files, virtual or otherwise.<\/p>\n<p>To get a URI for a virtual document in your app, first you create an <code>[Intent](https:\/\/developer.android.com\/reference\/android\/content\/Intent.html)<\/code> to open the file picker UI. Since an app cannot directly open a virtual file by using the <code>[openInputStream()](https:\/\/developer.android.com\/reference\/android\/content\/ContentResolver.html#openInputStream(android.net.Uri))<\/code> method, your app does not receive any virtual files if you include the <code>[CATEGORY_OPENABLE](https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#CATEGORY_OPENABLE)<\/code> category.<\/p>\n<p>After the user has made a selection, the system calls the <code>[onActivityResult()](https:\/\/developer.android.com\/reference\/android\/app\/Activity.html#onActivityResult(int, int, android.content.Intent))<\/code> method. Your app can retrieve the URI of the virtual file and get an input stream, as demonstrated in the code snippet below.<\/p>\n<p>\u5e2b\u723a\u4f86\u8aaa\u8aaa\u9019\u662f\u5565\uff0c\u5c31\u662f\u4ee5\u524d\u96d6\u7136\u53ef\u4ee5\u5229\u7528 Storage Access Framework \u62ff\u5230\u96f2\u7aef\u7a7a\u9593\u7684 URI\uff0c\u4f46\u662f\u56e0\u70ba\u96f2\u7aef\u6587\u4ef6\u6c92\u6709\u5728\u672c\u5730\u7aef\u7684\u76f4\u63a5 bytecode \u90a3\u5c31\u7121\u6cd5\u88ab\u986f\u793a\u51fa\u4f86\u8b93\u4f7f\u7528\u8005\u9078\u64c7\uff08\u9019\u6bb5\u8a71\u8d85\u96e3\u7406\u89e3\uff0c\u7c21\u55ae\u4f86\u8aaa\u5c31\u662f\u00a0<code>[ACTION_VIEW](https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#ACTION_VIEW)<\/code> intent \u6c92\u8fa6\u6cd5\u627e\u5230\u9019\u500b\u96f2\u7aef\u6587\u9593 URI \u7684\u6a94\u6848\uff09\uff0c\u90a3\u73fe\u5728\u52a0\u5165 virtual file \u7684\u6982\u5ff5\uff0c\u9019\u6771\u897f\u53ef\u4ee5\u88ab\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/provider\/DocumentsProvider.html\">DocumentsProvider<\/a>\u00a0\u627e\u5230\uff0c\u4f46\u662f\u7562\u7adf virtual file \u4e26\u4e0d\u5b58\u5728\u65bc local \uff0c\u6240\u4ee5\u5c31\u7b97\u73fe\u5728\u53ef\u4ee5\u7528\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#ACTION_VIEW\">ACTION_VIEW<\/a>\u00a0\u627e\u5230\uff0c\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/content\/ContentResolver.html#openInputStream(android.net.Uri)\">openInputStream<\/a>\u00a0\u4f9d\u7136\u7121\u6cd5\u5b58\u53d6 byte code.\u90a3\u8981\u600e\u9ebc\u8fa6\u5462\uff0c\u6211\u7d66\u4f60 code \u4f60\u53c3\u8003\u53c3\u8003\u3002<\/p>\n<p>\u5343\u8a00\u842c\u8a9e\u4e0d\u5982\u4f86\u6bb5 code<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-comment\">\/\/ Other Activity code ...<\/span>\n\n  <span class=\"hljs-keyword\">final<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-type\">int<\/span> <span class=\"hljs-variable\">REQUEST_CODE<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-number\">64<\/span>;\n\n  <span class=\"hljs-comment\">\/\/ We listen to the OnActivityResult event to respond to the user&#x27;s selection.<\/span>\n  <span class=\"hljs-meta\">@Override<\/span>\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">onActivityResult<\/span><span class=\"hljs-params\">(<span class=\"hljs-type\">int<\/span> requestCode, <span class=\"hljs-type\">int<\/span> resultCode,\n    Intent resultData)<\/span> {\n      <span class=\"hljs-keyword\">try<\/span> {\n        <span class=\"hljs-keyword\">if<\/span> (requestCode == REQUEST_CODE &amp;&amp;\n            resultCode == Activity.RESULT_OK) {\n\n            <span class=\"hljs-type\">Uri<\/span> <span class=\"hljs-variable\">uri<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-literal\">null<\/span>;\n\n            <span class=\"hljs-keyword\">if<\/span> (resultData != <span class=\"hljs-literal\">null<\/span>) {\n                uri = resultData.getData();\n\n                <span class=\"hljs-type\">ContentResolver<\/span> <span class=\"hljs-variable\">resolver<\/span> <span class=\"hljs-operator\">=<\/span> getContentResolver();\n\n                <span class=\"hljs-comment\">\/\/ Before attempting to coerce a file into a MIME type,<\/span>\n                <span class=\"hljs-comment\">\/\/ check to see what alternative MIME types are available to<\/span>\n                <span class=\"hljs-comment\">\/\/ coerce this file into.<\/span>\n                <span class=\"hljs-type\">String<\/span>[] <span class=\"hljs-variable\">streamTypes<\/span> <span class=\"hljs-operator\">=<\/span>\n                  resolver.getStreamTypes(uri, <span class=\"hljs-string\">&quot;*\/*&quot;<\/span>);\n\n                <span class=\"hljs-type\">AssetFileDescriptor<\/span> <span class=\"hljs-variable\">descriptor<\/span> <span class=\"hljs-operator\">=<\/span>\n                    resolver.openTypedAssetFileDescriptor(\n                        uri,\n                        streamTypes[<span class=\"hljs-number\">0<\/span>],\n                        <span class=\"hljs-literal\">null<\/span>);\n\n                <span class=\"hljs-comment\">\/\/ Retrieve a stream to the virtual file.<\/span>\n                <span class=\"hljs-type\">InputStream<\/span> <span class=\"hljs-variable\">inputStream<\/span> <span class=\"hljs-operator\">=<\/span> descriptor.createInputStream();\n            }\n        }\n      } <span class=\"hljs-keyword\">catch<\/span> (Exception ex) {\n        Log.e(<span class=\"hljs-string\">&quot;EXCEPTION&quot;<\/span>, <span class=\"hljs-string\">&quot;ERROR: &quot;<\/span>, ex);\n      }\n  }<\/code><\/pre>\n<p>\u5e95\u4e0b\u662f\u4e00\u822c\u60c5\u6cc1\uff0c\u975e virtual file<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-meta\">@Override<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">onActivityResult<\/span><span class=\"hljs-params\">(<span class=\"hljs-type\">int<\/span> requestCode, <span class=\"hljs-type\">int<\/span> resultCode,\n        Intent resultData)<\/span> {\n\n    <span class=\"hljs-comment\">\/\/ The ACTION_OPEN_DOCUMENT intent was sent with the request code<\/span>\n    <span class=\"hljs-comment\">\/\/ READ_REQUEST_CODE. If the request code seen here doesn&#x27;t match, it&#x27;s the<\/span>\n    <span class=\"hljs-comment\">\/\/ response to some other intent, and the code below shouldn&#x27;t run at all.<\/span>\n\n    <span class=\"hljs-keyword\">if<\/span> (requestCode == READ_REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK) {\n        <span class=\"hljs-comment\">\/\/ The document selected by the user won&#x27;t be returned in the intent.<\/span>\n        <span class=\"hljs-comment\">\/\/ Instead, a URI to that document will be contained in the return intent<\/span>\n        <span class=\"hljs-comment\">\/\/ provided to this method as a parameter.<\/span>\n        <span class=\"hljs-comment\">\/\/ Pull that URI using resultData.getData().<\/span>\n        <span class=\"hljs-type\">Uri<\/span> <span class=\"hljs-variable\">uri<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-literal\">null<\/span>;\n        <span class=\"hljs-keyword\">if<\/span> (resultData != <span class=\"hljs-literal\">null<\/span>) {\n            uri = resultData.getData();\n            Log.i(TAG, <span class=\"hljs-string\">&quot;Uri: &quot;<\/span> + uri.toString());\n            showImage(uri);\n        }\n    }\n}<\/code><\/pre>\n<p>\u7e3d\u7d50\uff1a\u7121\u611f\uff0c\u56e0\u70ba\u6211\u9084\u662f\u4e0d\u592a\u7406\u89e3\u76f4\u63a5\u7684\u61c9\u7528\u9ede\u5728\u54ea\uff1f\u800c\u4e14\u4ed6\u7684\u82f1\u6587\u63cf\u8ff0\u4e0d\u592a\u597d\u61c2\uff0c\u5e0c\u671b\u6211\u6c92\u6709\u7406\u89e3\u932f\u3002\u6b61\u8fce\u5927\u5bb6\u6307\u6559\u3002<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/training\/articles\/direct-boot.html\">Supporting Direct Boot \u76f4\u63a5\u958b\u6a5f<\/a><\/h4>\n<p>\u76f4\u63a5\u958b\u6a5f\u53ef\u52a0\u901f\u88dd\u7f6e\u555f\u52d5\u6642\u9593\uff0c\u4e26\u8b93\u5df2\u8a3b\u518a\u7684\u61c9\u7528\u7a0b\u5f0f\u53ea\u80fd\u4f7f\u7528\u6709\u9650\u7684\u529f\u80fd (\u5373\u4f7f\u5728\u672a\u9810\u671f\u7684\u91cd\u65b0\u958b\u6a5f\u4e4b\u5f8c)\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e00\u500b\u52a0\u5bc6\u88dd\u7f6e\u5728\u4f7f\u7528\u8005\u7761\u89ba\u6642\u91cd\u65b0\u958b\u6a5f\uff0c\u5df2\u8a3b\u518a\u7684\u9b27\u9418\u3001\u8a0a\u606f\u8207\u4f86\u96fb\u73fe\u5728\u53ef\u4ee5\u6301\u7e8c\u5982\u5e38\u901a\u77e5\u4f7f\u7528\u8005\u3002\u9019\u4e5f\u8868\u793a\u5354\u52a9\u5de5\u5177\u670d\u52d9\u5728\u91cd\u65b0\u555f\u52d5\u4e4b\u5f8c\u53ef\u7acb\u5373\u4f7f\u7528\u3002<\/p>\n<p>\u70ba\u4e86\u9054\u5230\u4e0a\u8ff0\u7684\u76ee\u7684\uff0cAndroid N \u6703\u5728\u4e00\u500b\u5b89\u5168\u7684 <em>\u76f4\u63a5\u958b\u6a5f<\/em> \u6a21\u5f0f\u4e0b\u57f7\u884c\uff0c\u9019\u662f\u88dd\u7f6e\u5df2\u7d93\u958b\u555f\u96fb\u6e90\u4f46\u4f7f\u7528\u8005\u5c1a\u672a\u89e3\u9396\u88dd\u7f6e\u7684\u671f\u9593\u3002 \u70ba\u4e86\u652f\u63f4\u9019\u7a2e\u65b9\u5f0f\uff0c\u7cfb\u7d71\u70ba\u8cc7\u6599\u63d0\u4f9b\u5169\u500b\u5132\u5b58\u4f4d\u7f6e\uff1a<\/p>\n<ul>\n<li>\n<p><em>\u8a8d\u8b49\u52a0\u5bc6\u7684\u5132\u5b58\u7a7a\u9593<\/em>\uff1a\u9019\u662f\u9810\u8a2d\u7684\u5132\u5b58\u4f4d\u7f6e\uff0c\u53ea\u6709\u5728\u4f7f\u7528\u8005\u89e3\u9396\u88dd\u7f6e\u4e4b\u5f8c\u624d\u80fd\u4f7f\u7528\u3002<\/p>\n<\/li>\n<li>\n<p><em>\u88dd\u7f6e\u52a0\u5bc6\u7684\u5132\u5b58\u7a7a\u9593<\/em>\uff1a\u9019\u662f\u300c\u76f4\u63a5\u958b\u6a5f\u300d\u6a21\u5f0f\u671f\u9593\u8207\u4f7f\u7528\u8005\u89e3\u9396\u88dd\u7f6e\u4e4b\u5f8c\u90fd\u53ef\u4ee5\u4f7f\u7528\u7684\u5132\u5b58\u4f4d\u7f6e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u9019\u500b\u90e8\u5206\u6211\u8a8d\u70ba\u61c9\u8a72\u548c [file-based encryption (FBE)](<a href=\"http:\/\/file-based\">http:\/\/file-based<\/a> encryption (FBE))\u00a0\u4e00\u8d77\u770b\uff0c\u5728 Android N \u4e4b\u524d\u5168\u90e8\u90fd\u662f full-disk encryption \uff0c\u800c\u9019\u4e00\u7248\u6539\u6210 FBE \uff0c\u9019\u76f4\u63a5\u53d7\u76ca\u90e8\u5206\u5c31\u662f\u76f4\u63a5\u958b\u6a5f\u3002<\/p>\n<p>\u300eFile-based encryption enables a new feature introduced in Android 7.0 called <a href=\"https:\/\/developer.android.com\/preview\/features\/direct-boot.html\">Direct Boot<\/a>. Direct Boot allows encrypted devices to boot straight to the lock screen. Previously, on encrypted devices using <a href=\"https:\/\/source.android.com\/security\/encryption\/full-disk.html\">full disk encryption<\/a> (FDE), users needed to provided credentials before any data could be accessed, preventing the phone from performing all but the most basic of operations\u3002\u300f<\/p>\n<p>\u7531\u65bc\u53ef\u4ee5\u5728\u5169\u7a2e\u7a7a\u9593\u4e0a\u9032\u884c\u5207\u63db\uff0c\u90a3\u5c0d\u65bc\u958b\u767c\u8005\u4f86\u8aaa\u9700\u8981\u6ce8\u610f\u7684\u662f \u5207\u63db\u9ede\u4ee5\u53ca\u5169\u908a\u8cc7\u6599\u6574\u5408\u3002\u5148\u8a3b\u518a broadcastReceiver<\/p>\n<pre><code class=\"hljs language-plaintext\">android.intent.action.ACTION_LOCKED_BOOT_COMPLETED<\/code><\/pre>\n<p>Getting Notified of User Unlock<\/p>\n<ul>\n<li>\n<p>If your app has foreground processes that need immediate notification, listen for the\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#ACTION_USER_UNLOCKED\">ACTION_USER_UNLOCKED<\/a>\u00a0message.<\/p>\n<\/li>\n<li>\n<p>If your app only uses background processes that can act on a delayed notification, listen for the\u00a0<a href=\"https:\/\/developer.android.com\/reference\/android\/content\/Intent.html#ACTION_BOOT_COMPLETED\">ACTION_BOOT_COMPLETED<\/a>\u00a0message.<\/p>\n<\/li>\n<\/ul>\n<p>Migrating Existing Data<\/p>\n<p>Use\u00a0Context.moveSharedPreferencesFrom()\u00a0and\u00a0Context.moveDatabaseFrom()\u00a0to migrate preference and database data between credential encrypted storage and device encrypted storage.<\/p>\n<pre><code class=\"hljs language-java\"><span class=\"hljs-type\">Context<\/span> <span class=\"hljs-variable\">directBootContext<\/span> <span class=\"hljs-operator\">=<\/span> appContext.createDeviceProtectedStorageContext();\n<span class=\"hljs-comment\">\/\/ Access appDataFilename that lives in device encrypted storage<\/span>\n<span class=\"hljs-type\">FileInputStream<\/span> <span class=\"hljs-variable\">inStream<\/span> <span class=\"hljs-operator\">=<\/span> directBootContext.openFileInput(appDataFilename);\n<span class=\"hljs-comment\">\/\/ Use inStream to read content...<\/span><\/code><\/pre>\n<p>\u7e3d\u7d50\uff1a\u6211\u600e\u9ebc\u89ba\u5f97 mtk \u6709\u500b\u95dc\u6a5f\u9b27\u9418\uff0c\u90a3\u5230\u5e95\u600e\u9ebc\u5f04\u7684\u3002\u9019\u6b21 Android N \u5728\u7cfb\u7d71\u5c64\u9762\u7684\u5b89\u5168\u6027\u771f\u7684\u5f37\u5316\u4e0d\u5c11\u3002<\/p>\n<h4><a href=\"https:\/\/www.android.com\/work\/\">Android for Work Updates<\/a><\/h4>\n<p>\u4f86\u6bb5\u5ee3\u544a\u8a5e\u300eAndroid for Work \u662f\u5354\u52a9\u4f01\u696d\u4f7f\u7528 Android \u7684\u65b9\u6848\uff0c\u5305\u62ec Android \u7684\u7522\u54c1\u529f\u80fd\u3001Google Play for Work \u53ca\u5176\u4ed6\u751f\u7522\u529b\u5de5\u5177\u3002Android for Work \u4e3b\u8981\u900f\u904e API \u767c\u4f48\uff0c\u53ef\u8b93\u4f01\u696d\u884c\u52d5\u7ba1\u7406\u670d\u52d9 (EMM) \u4f9b\u61c9\u5546\u548c\u4f01\u696d\u61c9\u7528\u7a0b\u5f0f\u958b\u767c\u5546\u70ba\u5ba2\u6236\u54e1\u5de5\u63d0\u4f9b\u5b89\u5168\u3001\u6709\u6548\u7387\u800c\u591a\u5143\u5316\u7684\u884c\u52d5\u74b0\u5883\u3002<\/p>\n<ul>\n<li>\n<p><strong>Work profile security challenge<\/strong><\/p>\n<\/li>\n<li>\n<p>\u8a2d\u5b9a\u6a94\u64c1\u6709\u8005\u53ef\u4ee5\u70ba\u4ee5\u5de5\u4f5c\u8a2d\u5b9a\u6a94\u57f7\u884c\u4e4b\u61c9\u7528\u7a0b\u5f0f\u6307\u5b9a\u500b\u5225\u7684\u5b89\u5168\u6027\u67e5\u554f\u3002\u7576\u4f7f\u7528\u8005\u5617\u8a66\u958b\u555f\u4efb\u4f55\u5de5\u4f5c\u61c9\u7528\u7a0b\u5f0f\u6642\u6703\u986f\u793a\u5de5\u4f5c\u67e5\u554f\u3002\u6210\u529f\u5b8c\u6210\u5b89\u5168\u6027\u67e5\u554f\u53ef\u5c07\u5de5\u4f5c\u8a2d\u5b9a\u6a94\u89e3\u9396\u4e26\u5728\u5fc5\u8981\u6642\u5c07\u5b83\u89e3\u5bc6\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Toggle Work Mode<\/strong><\/p>\n<\/li>\n<li>\n<p>\u5728\u5177\u6709\u5de5\u4f5c\u8a2d\u5b9a\u6a94\u7684\u88dd\u7f6e\u4e0a\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u5207\u63db\u5de5\u4f5c\u6a21\u5f0f\u3002\u7576\u5de5\u4f5c\u6a21\u5f0f\u95dc\u9589\u6642\uff0c\u53d7\u7ba1\u7406\u7684\u4f7f\u7528\u8005\u6703\u66ab\u6642\u95dc\u6a5f\uff0c\u56e0\u6b64\u800c\u505c\u7528\u5de5\u4f5c\u8a2d\u5b9a\u6a94\u61c9\u7528\u7a0b\u5f0f\u3001\u80cc\u666f\u540c\u6b65\u8207\u901a\u77e5\u3002\u9019\u4e5f\u5305\u62ec\u8a2d\u5b9a\u6a94\u64c1\u6709\u8005\u61c9\u7528\u7a0b\u5f0f\u3002\u7576\u5de5\u4f5c\u6a21\u5f0f\u95dc\u9589\u6642\uff0c\u7cfb\u7d71\u6703\u986f\u793a\u6301\u7e8c\u7684\u72c0\u614b\u5716\u793a\uff0c\u63d0\u9192\u4f7f\u7528\u8005\u4ed6\u5011\u7121\u6cd5\u555f\u52d5\u5de5\u4f5c\u61c9\u7528\u7a0b\u5f0f\u3002\u555f\u52d5\u5668\u6703\u6307\u51fa\u5de5\u4f5c\u61c9\u7528\u7a0b\u5f0f\u548c\u5c0f\u5de5\u5177\u7121\u6cd5\u5b58\u53d6\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Always-On VPN<\/strong><\/p>\n<\/li>\n<li>\n<p>\u88dd\u7f6e\u64c1\u6709\u8005\u548c\u8a2d\u5b9a\u6a94\u64c1\u6709\u8005\u53ef\u78ba\u4fdd\u5de5\u4f5c\u61c9\u7528\u7a0b\u5f0f\u4e00\u5f8b\u900f\u904e\u6307\u5b9a\u7684 VPN \u9023\u7dda\u3002\u7cfb\u7d71\u6703\u81ea\u52d5\u5728\u88dd\u7f6e\u958b\u6a5f\u6642\u555f\u52d5\u8a72 VPN\u3002\u65b0\u7684 <code>DevicePolicyManager<\/code> \u65b9\u6cd5\u662f <code>setAlwaysOnVpnPackage()<\/code> \u8207 <code>getAlwaysOnVpnPackage()<\/code>\u3002\u56e0\u70ba\u7cfb\u7d71\u7121\u9700\u900f\u904e\u61c9\u7528\u7a0b\u5f0f\u4e92\u52d5\u5373\u53ef\u76f4\u63a5\u9023\u7d50 VPN \u670d\u52d9\uff0c\u6240\u4ee5 VPN \u7528\u6236\u7aef\u9700\u8981\u70ba\u300c\u4e00\u5f8b\u958b\u555f\u7684 VPN\u300d\u8655\u7406\u65b0\u7684\u9032\u5165\u9ede\u3002\u6b63\u5982\u4ee5\u5f80\uff0c\u900f\u904e\u7b26\u5408\u52d5\u4f5c<code>android.net.VpnService<\/code> \u7684\u610f\u5716\u7be9\u9078\u5668\u5411\u7cfb\u7d71\u6307\u660e\u670d\u52d9\u3002\u4f7f\u7528\u8005\u4e5f\u53ef\u4ee5\u4f7f\u7528 [\u8a2d\u5b9a] &gt; [\u66f4\u591a] &gt; [VPN] \u624b\u52d5\u8a2d\u5b9a\u300c\u4e00\u5f8b\u958b\u555f\u7684 VPN\u300d\u7528\u6236\u7aef\uff0c\u9019\u4e9b\u7528\u6236\u7aef\u5728\u4e3b\u8981\u4f7f\u7528\u8005\u4e2d\u5be6\u4f5c <code>VPNService<\/code> \u65b9\u6cd5\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Customized provisioning<\/strong><\/p>\n<\/li>\n<li>\n<p>An application can customize the profile owner and device owner provisioning flows with corporate colors and logos.\u00a0<code>DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR<\/code> customizes flow color. <code>DevicePolicyManager.EXTRA_PROVISIONING_LOGO_URI<\/code>customizes the flow with a corporate logo.<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u8005\u53ef\u4ee5\u81ea\u5df1\u5b9a\u7fa9\u9a57\u8b49\u6d41\u7a0b\u7684\u4e3b\u8981\u984f\u8272\uff0c\u6216\u662f\u653e\u7f6e\u516c\u53f8 logo \u3002\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u7e3d\u7d50\uff1a\u9019\u500b\u6211\u771f\u7684\u9023\u73a9\u90fd\u6c92\u73a9\u904e\uff0c\u66f4\u5225\u8aaa\u958b\u767c\u3002\u611f\u89ba always-on vpn \u9084\u883b\u5be6\u7528\u7684\u3002google \u771f\u7684\u8d8a\u4f86\u8d8a\u91cd\u8996 BYOD\uff0c\u9664\u4e86\u5340\u5206\u5de5\u4f5c\u8207\u500b\u4eba\uff0c\u5b89\u5168\u6027\u66f4\u662f\u4e00\u5927\u91cd\u9ede\u3002\u6211\u5728\u770b api \u6642\u767c\u73fe\u53ef\u4ee5\u76f4\u63a5\u8b80\u53d6\u516c\u53f8\u7684 calendar, email user contact\u3002\u611f\u89ba\u5f88\u597d\u7528\u554a\u3002<\/p>\n<h4><a href=\"https:\/\/developer.android.com\/guide\/platform\/j8-jack.html?hl=en\">Java 8 Language features JAVA 8 \u652f\u63f4<\/a><\/h4>\n<p>Android does not currently support all Java 8 language features. However, the following features are now available when developing apps targeting the Android N Preview:<\/p>\n<p>\u9808\u4f7f\u7528 Android Studio 2.1 (\u9810\u89bd\u7248) \u8207 Android N Preview SDK\uff0c\u5176\u4e2d\u5305\u62ec\u5fc5\u8981\u7684 Jack tool chain \u8207\u9069\u7528\u65bc Gradle \u7684\u5df2\u66f4\u65b0 Android \u5916\u639b\u7a0b\u5f0f\u3002<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/IandI\/defaultmethods.html\">Default and static interface methods<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/lambdaexpressions.html\">Lambda expressions<\/a>\u00a0(also available on API level 23 and lower)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/annotations\/repeating.html\">Repeatable annotations<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/methodreferences.html\">Method References<\/a>\u00a0(also available on API level 23 and lower)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/annotations\/type_annotations.html\">Type Annotations<\/a>\u00a0(also available on API level 23 and lower)<\/p>\n<\/li>\n<\/ul>\n<p>\u7e3d\u7d50\uff1a\u5343\u547c\u842c\u559a\u59cb\u51fa\u4f86\uff0c\u7b2c\u4e8c\u9805\u7684\u00a0Lambda \u9019\u6771\u897f\u5f9e\u597d\u4e45\u4e4b\u524d\u5c31\u4e0d\u5c11\u4eba\u5f88\u60f3\u62c9\u9032 Android\uff0c\u9084\u5f04\u500b\u00a0Retrolambda \u4f86\u5690\u9bae\uff0c\u4e0d\u904e\u6211\u500b\u4eba\u7528\u7684\u4e0d\u592a\u7fd2\u6163\u554a\u3002\u6b64\u5916\uff0c\u90fd\u5df2\u7d93\u63d0\u5230 Java 8 \uff0c\u90a3\u600e\u9ebc\u53ef\u4ee5\u4e0d\u63d0 <a href=\"https:\/\/source.android.com\/source\/jack.html\">Jack (Java Android Compiler Kit )<\/a>and Jill (Jack Intermediate Library Linker)\uff0c\u4f46\u76ee\u524d\u770b\u8d77\u4f86\u6548\u80fd\u5dee\u7570\u4e0d\u5927\uff0c\u6700\u76f4\u63a5\u53d7\u76ca\u5c31\u662f\u6c92\u6709 \u300e65k method limit\u300f \u554f\u984c\u3002<\/p>\n<ul>\n<li>Legacy javac toolchain:<\/li>\n<\/ul>\n<p><strong>javac<\/strong> (<code>.java<\/code> \u2192 <code>.class<\/code>) \u2192 <strong>dx<\/strong> (<code>.class<\/code> \u2192 <code>.dex<\/code>)<\/p>\n<ul>\n<li>New Jack toolchain:<\/li>\n<\/ul>\n<p><strong>Jack<\/strong> (<code>.java<\/code> \u2192 <code>.jack<\/code> \u2192 <code>.dex<\/code>)<\/p>\n<p>\u7136\u5f8c\u9019\u88e1\u6709\u500b\u5927\u795e\u5beb\u5f97\u975e\u5e38\u597d\uff0c<a href=\"http:\/\/taobaofed.org\/blog\/2016\/05\/05\/new-compiler-for-android\/\">Android \u65b0\u4e00\u4ee3\u7f16\u8bd1 toolchain Jack &amp; Jill \u7b80\u4ecb<\/a><\/p>\n<h4><\/h4>\n<h4>Profile-guided JIT\/AOT Compilation\u00a0\u8a2d\u5b9a\u6a94\u6307\u5f15 JIT\/AOT \u7de8\u8b6f<\/h4>\n<p>\u5728 Android N \u4e2d\uff0c\u6211\u5011\u65b0\u589e\u4e86 Just in Time (JIT) \u7de8\u8b6f\u5668\u642d\u914d\u7a0b\u5f0f\u78bc\u5206\u6790\u5de5\u5177\u5230 ART\uff0c\u8b93 Android \u61c9\u7528\u7a0b\u5f0f\u5728\u57f7\u884c\u6642\u80fd\u5920\u6301\u7e8c\u6539\u5584\u5176\u6548\u80fd\u3002JIT \u7de8\u8b6f\u5668\u88dc\u5145\u4e86 ART \u76ee\u524d\u7684 Ahead of Time (AOT) \u7de8\u8b6f\u5668\uff0c\u5354\u52a9\u6539\u5584\u57f7\u884c\u968e\u6bb5\u6548\u80fd\u3001\u7bc0\u7701\u5132\u5b58\u7a7a\u9593\u4ee5\u53ca\u52a0\u901f\u61c9\u7528\u7a0b\u5f0f\u66f4\u65b0\u548c\u7cfb\u7d71\u66f4\u65b0\u3002<\/p>\n<p>\u8a2d\u5b9a\u6a94\u6307\u5f15\u7de8\u8b6f\u8b93 ART \u6839\u64da\u6bcf\u500b\u61c9\u7528\u7a0b\u5f0f\u7684\u5be6\u969b\u7528\u60c5\u5f62\u8207\u88dd\u7f6e\u4e0a\u7684\u60c5\u6cc1\u4f86\u7ba1\u7406\u5176 AOT\/JIT \u7de8\u8b6f\u3002\u4f8b\u5982\uff0cART \u6703\u7dad\u8b77\u6bcf\u500b\u61c9\u7528\u7a0b\u5f0f\u5e38\u7528\u65b9\u6cd5\u7684\u8a2d\u5b9a\u6a94\uff0c\u800c\u4e14\u53ef\u4ee5\u9810\u5148\u7de8\u8b6f\u548c\u5feb\u53d6\u90a3\u4e9b\u65b9\u6cd5\u4ee5\u7372\u5f97\u6700\u4f73\u6548\u80fd\u3002\u5b83\u4e0d\u6703\u7de8\u8b6f\u61c9\u7528\u7a0b\u5f0f\u7684\u5176\u4ed6\u90e8\u5206\uff0c\u76f4\u5230\u5be6\u969b\u8981\u4f7f\u7528\u9019\u4e9b\u90e8\u5206\u6642\u624d\u6703\u7de8\u8b6f\u3002<\/p>\n<p>\u9664\u4e86\u6539\u5584\u61c9\u7528\u7a0b\u5f0f\u95dc\u9375\u90e8\u5206\u7684\u6548\u80fd\u4ee5\u5916\uff0c\u8a2d\u5b9a\u6a94\u6307\u5f15\u7de8\u8b6f\u9084\u6709\u52a9\u65bc\u964d\u4f4e\u61c9\u7528\u7a0b\u5f0f\u7684\u6574\u9ad4 RAM \u4f7f\u7528\u91cf\uff0c\u5305\u62ec\u95dc\u806f\u7684\u4e8c\u9032\u4f4d\u6a94\u6848\u3002\u6b64\u529f\u80fd\u5c0d\u65bc\u4f4e\u8a18\u61b6\u9ad4\u88dd\u7f6e\u7279\u5225\u91cd\u8981\u3002<\/p>\n<p>ART \u900f\u904e\u5c0d\u88dd\u7f6e\u96fb\u6c60\u7522\u751f\u6700\u5c0f\u5f71\u97ff\u7684\u65b9\u5f0f\u4f86\u7ba1\u7406\u8a2d\u5b9a\u6a94\u6307\u5f15\u7de8\u8b6f\u3002\u5b83\u53ea\u6703\u5728\u88dd\u7f6e\u9592\u7f6e\u548c\u5145\u96fb\u6642\u9810\u5148\u7de8\u8b6f\uff0c\u9019\u7a2e\u9810\u5148\u5de5\u4f5c\u7684\u65b9\u5f0f\u53ef\u4ee5\u7bc0\u7701\u6642\u9593\u548c\u96fb\u6c60\u96fb\u529b\u3002<\/p>\n<p>\u7e3d\u7d50\uff1aAndroid M \u7684\u6642\u5019\uff0c\u53ea\u6709\u5728 apk \u5b89\u88dd\u6642\u624d\u6703\u7de8\u8b6f\u3002\u9019\u500b\u8aaa\u4f86\u615a\u6127\uff0c\u655d\u53f8\u66fe\u7d93\u51fa\u904e\u4e00\u96bb\u8d85\u4f4e\u968e\u624b\u6a5f\uff08512mb \u9084\u662f 256 mb\uff09\uff0c\u7cfb\u7d71\u66f4\u65b0\u6162\u5230\u4ee5\u70ba\u7576\u6a5f\uff0c\u4f46\u662f\u7b49\u500b\uff12\uff10\u5206\u9418\uff0c\u9084\u662f\u6210\u529f\u4e86\uff0c\u4f46\u662f\u597d\u6232\u9084\u5728\u5f8c\u982d\uff0c\u5c45\u7136\u4e0d\u80fd\u5b89\u88dd facebook app , \u9019\u9084\u80fd\u8ce3\u55ce\uff1f\u5c31\u662f\u56e0\u70ba\u5b89\u88dd\u6642\u7de8\u8b6f\u6d88\u8017\u5927\u91cf RAM \uff0c\u4f46\u662f\u624b\u6a5f\u592a\u721b\u4e86\uff0c\u5c31\u7576\u6a5f\u4e86\uff0c\u5c31\u7576\u6a5f\u4e86\uff0c\u5c31\u7576\u6a5f\u4e86\u3002\u6211\u60f3\u53ef\u80fd\u5c31\u662f\u4e0a\u9762\u9019\u4e9b\u554f\u984c\uff0c\u6240\u4ee5\u9084\u662f\u9000\u56de\u90e8\u5206\u5148\u7de8\u8b6f\u9019\u6a23\u6298\u8877\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u7b2c\u4e00\u7bc7\u5c31\u5230\u6b64\u70ba\u6b62\uff0c\u5269\u4e0b\u7684\u6703\u5728\u7b2c\u4e8c\u7bc7\u88dc\u5b8c(\u5e0c\u671b)\uff0c\u5982\u679c\u6709\u4efb\u4f55\u554f\u984c\u6216\u662f\u6211\u5beb\u932f\u7684\u90e8\u5206\uff0c\u6b61\u8fce\u5e95\u4e0b\u56de\u61c9\u3002\u6709\u8208\u8da3\u4e14\u6709\u6a5f\u5b50\u7684\u4eba\u53ef\u4ee5\u5229\u7528 <a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0-samples.html\">Google Sample<\/a>\u9032\u884c\u6e2c\u8a66\u3002<\/p>\n<p>reference:<\/p>\n<p><a href=\"https:\/\/developer.android.com\/about\/versions\/nougat\/android-7.0.html\">\u5b98\u65b9<\/a><\/p>\n<p><a href=\"https:\/\/www.youtube.com\/channel\/UCVHFbqXqoYvEWM1Ddxl0QDg\">\u5b98\u65b9\u5f71\u7247<\/a><\/p>\n<p>FB \u4e0a\u7684 <a href=\"https:\/\/www.facebook.com\/scottt.tw\">Scott Tsai<\/a>\u00a0\u7684<a href=\"https:\/\/www.facebook.com\/groups\/system.software2016\/permalink\/1097245500354954\/\">\u611f\u60f3<\/a><\/p>\n<p><a href=\"http:\/\/www.oschina.net\/translate\/android-security-implementation-of-self-signed-ssl\">\u4e3a\u4f60\u7684\u5b89\u5353\u5e94\u7528\u5b9e\u73b0\u81ea\u7b7e\u540d\u7684 SSL \u8bc1\u4e66<\/a><\/p>\n<p><a href=\"https:\/\/gank.io\/post\/56e0b83c67765963436fcb94\">\u4ece\u5f00\u53d1\u8005\u89d2\u5ea6\u89e3\u6790 Android N \u65b0\u7279\u6027\uff01<\/a><\/p>\n<p>Android M\u65b0\u7279\u6027Doze and App Standby\u6a21\u5f0f\u8be6\u89e3 \u2013 \u4e0d\u80fd\u8f49\u8f09<\/p>\n<p><a href=\"https:\/\/my.oschina.net\/lorcan\/blog\/539208\">Android 6.0\u7535\u6e90\u7ba1\u7406\u65b9\u5f0f<\/a><\/p>\n<p><a href=\"https:\/\/read01.com\/RM3RQ0.html\">Android N\u7684\u4e94\u9805\u5168\u65b0\u529f\u80fd\uff08\u52a0\u4e0a\u5206\u5c4f\uff09<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010Android 7.0 Nougat (API 24)\u3011 \u7cfb\u7d71\u5e95\u5c64\u67b6\u69cb\u3001\u591a\u91cd\u8996\u7a97\u3001JIT\/AOT \u7de8\u8b6f\u8207\u7db2\u8def [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[167],"tags":[173,174],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/180"}],"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=180"}],"version-history":[{"count":7,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":1562,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/1562"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}