{"id":1312,"date":"2016-02-22T17:39:35","date_gmt":"2016-02-22T09:39:35","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1312"},"modified":"2026-08-18T12:58:48","modified_gmt":"2026-08-18T04:58:48","slug":"android-%e9%a1%b9%e7%9b%ae%e9%87%8d%e6%9e%84%e4%b9%8b%e8%b7%af%ef%bc%9a%e6%9e%b6%e6%9e%84%e7%af%87","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1312","title":{"rendered":"Android \u9879\u76ee\u91cd\u6784\u4e4b\u8def\uff1a\u67b6\u6784\u7bc7"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u63a5\u624b\u4e00\u4e2a\u6309\u529f\u80fd\u5207\u5f97\u8fc7\u7ec6\u7684 Android \u9879\u76ee\uff1a17 \u4e2a\u6a21\u5757\u3001\u597d\u591a\u6a21\u5757\u53ea\u6709\u4e24\u4e09\u4e2a\u7c7b\uff0c\u5e94\u7528\u672c\u8eab\u6700\u591a\u4e94\u4e2a\u6a21\u5757\u5c31\u591f\u3002\u6a21\u5757\u8fb9\u754c\u6a21\u7cca\uff0c\u7c7b\u804c\u8d23\u4e0d\u6e05\uff0c\u627e Activity \u7ecf\u5e38\u53ea\u80fd\u7ffb Manifest\u3002\u4ee3\u7801\u53c8\u4e71\u53c8\u81ed\uff0c\u6539\u4e00\u4e2a bug \u5192\u51fa\u53e6\u4e00\u4e2a\uff0c\u6ca1\u6cd5\u505a\u65b0\u529f\u80fd\uff0c\u66f4\u6ee1\u8db3\u4e0d\u4e86\u591a\u5ba2\u6237\u5b9a\u5236\u3002\u4e8e\u662f\u91cd\u6784\uff1a\u642d\u4e00\u4e2a\u6613\u7ef4\u62a4\u3001\u6613\u6269\u5c55\u3001\u53ef\u5b9a\u5236\u7684\u56db\u5c42\u7ed3\u6784\u3002<\/p>\n<\/blockquote>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3498\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" width=\"2151\" height=\"1105\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png 2151w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-768x395.png 768w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-1536x789.png 1536w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-2048x1052.png 2048w\" sizes=\"(max-width: 2151px) 100vw, 2151px\" \/><\/a><\/p>\n<p style=\"margin: 1em 0px;\">\u56db\u5c42\uff1a\u6a21\u578b\u5c42\u3001\u63a5\u53e3\u5c42\u3001\u6838\u5fc3\u5c42\u3001\u754c\u9762\u5c42\u3002\u6a21\u578b\u5b9a\u4e49\u6570\u636e\uff1b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u7aef API\uff1b\u6838\u5fc3\u5904\u7406\u4e1a\u52a1\uff1b\u754c\u9762\u53ea\u8d1f\u8d23\u5c55\u793a\u3002\u5173\u7cfb\u5982\u4e0b\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" src=\"http:\/\/keeganlee.me\/android\/_image\/20150605\/Android_Structure.jpg\" alt=\"\" \/><\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e00\u3001\u63a5\u53e3\u5c42<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u5c01\u88c5\u7f51\u7edc\u5e95\u5c42 API\uff0c\u4f9b\u6838\u5fc3\u5c42\u8c03\u7528\u3002\u8d77\u6b65\u53ea\u7559 4 \u4e2a\u6838\u5fc3\u7c7b\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">PostEngine<\/code>\uff1a\u8bf7\u6c42\u5f15\u64ce\uff0c\u53d1\u9001\u8bf7\u6c42\u5e76\u5904\u7406\u54cd\u5e94<\/section>\n<\/li>\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">Response<\/code>\uff1a\u5c01\u88c5 Http \u8fd4\u56de\u7ed3\u6784<\/section>\n<\/li>\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">Api<\/code>\uff1a\u5b9a\u4e49\u5168\u90e8\u63a5\u53e3\u65b9\u6cd5<\/section>\n<\/li>\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">ApiImpl<\/code>\uff1a\u5b9e\u73b0\u5168\u90e8\u63a5\u53e3\u65b9\u6cd5<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">PostEngine \u628a\u8bf7\u6c42\u53d1\u51fa\u53bb\uff0c\u628a\u8fd4\u56de json \u8f6c\u6210 Response\u3002json \u7ed3\u6784\u56fa\u5b9a\u4e09\u7c7b\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">{&quot;event&quot;: &quot;0&quot;, &quot;msg&quot;: &quot;success&quot;}\n{&quot;event&quot;: &quot;0&quot;, &quot;msg&quot;: &quot;success&quot;, &quot;obj&quot;:{...}}\n{&quot;event&quot;: &quot;0&quot;, &quot;msg&quot;: &quot;success&quot;, &quot;objList&quot;:[{...}, {...}], &quot;currentPage&quot;: 1, &quot;pageSize&quot;: 20, &quot;maxCount&quot;: 2, &quot;maxPage&quot;: 1}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">event<\/code> \u662f\u8fd4\u56de\u7801\uff0c0 \u6210\u529f\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">msg<\/code> \u662f\u4fe1\u606f\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">obj<\/code> \u5355\u4e2a\u5bf9\u8c61\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">objList<\/code> \u6570\u7ec4\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">currentPage<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">pageSize<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">maxCount<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">maxPage<\/code> \u5206\u9875\u3002Response \u57fa\u672c\u5b9a\u4e49\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public class Response&lt;T&gt; {\n    private String event;\n    private String msg;\n    private T obj;\n    private T objList;\n    private int currentPage;\n    private int pageSize;\n    private int maxCount;\n    private int maxPage;\n\n    \/\/getter\u548csetter\u65b9\u6cd5\n    ...\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5c5e\u6027\u540d\u5fc5\u987b\u548c json \u5b57\u6bb5\u4e00\u81f4\uff0c\u5426\u5219\u8f6c\u4e0d\u51fa\u6765\u3002obj \/ objList \u7528\u6cdb\u578b\u5bf9\u5e94\u5177\u4f53\u7c7b\u578b\u3002Api \u65b9\u6cd5\u7c7b\u4f3c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public Response&lt;Void&gt; login(String loginName, String password);\npublic Response&lt;VersionInfo&gt; getLastVersion();\npublic Response&lt;List&lt;Coupon&gt;&gt; listNewCoupon(int currentPage, int pageSize);<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">ApiImpl \u628a\u53c2\u6570\u548c\u8fd4\u56de\u7c7b\u578b\u5907\u597d\uff0c\u4ea4\u7ed9 PostEngine\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">@Override\npublic Response&lt;Void&gt; login(String loginName, String password) {\n    try {\n        String method = Api.LOGIN;\n        List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();\n        params.add(new BasicNameValuePair(&quot;loginName&quot;, loginName));\n        params.add(new BasicNameValuePair(&quot;password&quot;, EncryptUtil.makeMD5(password)));\n        TypeToken&lt;Response&lt;Void&gt;&gt; typeToken = new TypeToken&lt;Response&lt;Void&gt;&gt;(){};\n        return postEngine.specialHandle(method, params, typeToken);\n    } catch (Exception e) {\n        \/\/\u5f02\u5e38\u5904\u7406\n    }\n}<\/code><\/pre>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e8c\u3001\u6838\u5fc3\u5c42<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u5939\u5728\u63a5\u53e3\u5c42\u548c\u754c\u9762\u5c42\u4e4b\u95f4\uff0c\u96c6\u4e2d\u505a\u6570\u636e\u5904\u7406\u3002\u5411\u4e0a\u7ed9\u754c\u9762 Action\uff1b\u5411\u4e0b\u8c03\u63a5\u53e3\u5c42\u8bf7\u6c42\u670d\u52a1\u5668\u3002Action \u7c7b\u4f3c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public void getCustomer(String loginName, CallbackListener&lt;Customer&gt; callbackListener);<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u56e0\u4e3a\u8981\u8bf7\u6c42\u7f51\u7edc\uff0c\u52a0\u4e86 callback\u3002CallbackListener \u53ea\u6709\u6210\u529f\/\u5931\u8d25\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public interface CallbackListener&lt;T&gt; {\n    \/**\n     * \u8bf7\u6c42\u7684\u54cd\u5e94\u7ed3\u679c\u4e3a\u6210\u529f\u65f6\u8c03\u7528\n     * @param data  \u8fd4\u56de\u7684\u6570\u636e\n     *\/\n    public void onSuccess(T data);\n\n    \/**\n     * \u8bf7\u6c42\u7684\u54cd\u5e94\u7ed3\u679c\u4e3a\u5931\u8d25\u65f6\u8c03\u7528\n     * @param errorEvent \u9519\u8bef\u7801\n     * @param message    \u9519\u8bef\u4fe1\u606f\n     *\/\n    public void onFailure(String errorEvent, String message);\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5b9e\u73b0\u57fa\u672c\u4e24\u6b65\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u53c2\u6570\u68c0\u67e5\uff1a\u975e\u7a7a\u3001\u8fb9\u754c\u3001\u6709\u6548\u6027<\/section>\n<\/li>\n<li>\n<section>\u5f02\u6b65\u4efb\u52a1\u8c03\u63a5\u53e3\u5c42 Api\uff0c\u628a\u7ed3\u679c\u56de\u8c03\u56de\u53bb<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">Action \u9762\u5411\u754c\u9762\uff1a\u540c\u4e00\u5c4f\u6570\u636e\u53ef\u80fd\u8981\u8c03\u4e0d\u540c Api\u3002\u540e\u7eed\u53ef\u5728\u8fd9\u91cc\u52a0\u7f13\u5b58\uff0c\u4f46\u53d8\u5316\u592a\u5feb\u7684\u6570\u636e\u4e0d\u9002\u5408\u7f13\u5b58\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e09\u3001\u754c\u9762\u5c42<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6700\u4e0a\u5c42\uff0c\u53ea\u8d1f\u8d23\u5c55\u793a\u3002\u516c\u53f8\u8981\u7ed9\u4e0d\u540c\u5546\u6237\u5b9a\u5236\u4e0d\u540c app\uff0cAndroid Studio \u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">productFlavors<\/code> \u80fd\u5c11\u5f88\u591a\u91cd\u590d\u52b3\u52a8\u3002\u5305\u4e0d\u518d\u6309\u529f\u80fd\u6a21\u5757\u5207\uff0c\u800c\u6309\u7c7b\u578b\u5207\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" src=\"http:\/\/keeganlee.me\/android\/_image\/20150605\/package.jpg\" alt=\"\" \/><\/p>\n<p style=\"margin: 1em 0px;\">activity\u3001adapter\u3001fragment \u5404\u81ea\u6709\u57fa\u7c7b\uff0c\u62bd\u5171\u7528\u5e38\u91cf\u3001\u5bf9\u8c61\u548c\u65b9\u6cd5\u3002\u754c\u9762\u5c42\u6700\u5bb9\u6613\u4e71\u3001\u6700\u5bb9\u6613\u51fa\u95ee\u9898\uff0c\u67b6\u6784\u548c\u89c4\u8303\u90fd\u8981\u5148\u5b9a\u597d\u3002\u540e\u7eed\u6587\u7ae0\u518d\u5c55\u5f00\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u56db\u3001\u6a21\u578b\u5c42<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6a2a\u8de8\u5404\u5c42\uff0c\u5c01\u88c5\u6570\u636e\u5b9e\u4f53\uff0c\u57fa\u672c\u548c json \u7684 obj \u4e00\u81f4\u3002\u63a5\u53e3\u5c42\u628a obj \u8f6c\u6210\u5b9e\u4f53\uff0c\u518d\u7ecf Action \u5230\u754c\u9762\u3002\u8fd8\u5b9a\u4e49\u5e38\u91cf\uff1a\u7528\u6237\u72b6\u6001\u3001\u652f\u4ed8\u72b6\u6001\u7b49\u3002Api \u7528 1\u30012\u30013\uff0c\u8fd9\u91cc\u6539\u6210\u679a\u4e3e\uff0c\u514d\u53bb\u8fb9\u754c\u68c0\u67e5\uff0c\u4e5f\u66f4\u597d\u8bb0\u3002\u679a\u4e3e\u5fc5\u987b\u80fd\u628a 1\u30012\u30013 \u8f6c\u56de\u6765\uff0c\u4e24\u79cd\u505a\u6cd5\uff1a<\/p>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">1. gson @SerializedName<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public enum BooleanType {\n    @SerializedName(&quot;0&quot;)\n    FALSE,\n    @SerializedName(&quot;1&quot;)\n    TRUE\n}<\/code><\/pre>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">2. \u81ea\u5e26 value<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public enum BooleanType {\n    FALSE(&quot;0&quot;),\n    TRUE(&quot;1&quot;);\n\n    private String value;\n\n    BooleanType(String value) {\n        this.value = value;\n    }\n\n    public String getValue() {\n        return value;\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">gson \u65b9\u5f0f\u76f4\u63a5\u8bbf\u95ee TRUE\/FALSE \u5c31\u4f1a\u5e8f\u5217\u5316\u6210 1\/0\uff1b\u7b2c\u4e8c\u79cd\u6ca1\u6709\u5e8f\u5217\u5316\uff0c\u8981\u7528 getValue\u3002<\/p>\n<table style=\"border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; text-align: left; overflow: auto; display: table; overflow-wrap: break-word; word-break: break-all;\" width=\"817\">\n<thead>\n<tr>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u5c42\u7ea7<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u804c\u8d23<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u5173\u952e\u7c7b\u578b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u63a5\u53e3\u5c42<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u7f51\u7edc API\u3001json \u2192 Response<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">PostEngine \/ Response \/ Api \/ ApiImpl<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6838\u5fc3\u5c42<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u4e1a\u52a1\u4e0e\u6570\u636e\u5904\u7406\u3001\u56de\u8c03\u754c\u9762<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">Action \/ CallbackListener<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u754c\u9762\u5c42<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5c55\u793a\u3001\u591a flavor \u5b9a\u5236<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">activity \/ adapter \/ fragment \u57fa\u7c7b<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6a21\u578b\u5c42<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5b9e\u4f53\u4e0e\u72b6\u6001\u679a\u4e3e\uff0c\u8d2f\u7a7f\u5404\u5c42<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u4e0e json obj \u5bf9\u5e94\u7684 model<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e94\u3001\u7ed3\u675f<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u4ee5\u4e0a\u662f\u6700\u57fa\u672c\u7684\u67b6\u6784\uff0c\u53ea\u5217\u4e86\u6838\u5fc3\uff0c\u6269\u5c55\u662f\u4e0b\u4e00\u6b65\u3002\u539f\u6587\u51fa\u5904\uff1a <a href=\"http:\/\/keeganlee.me\/post\/android\/20150605\" target=\"_blank\" rel=\"noopener\">Keegan\u5c0f\u94a2<\/a><\/p>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><strong>\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u6a21\u5757\u5207\u592a\u788e\u5c31\u6309\u56db\u5c42\u91cd\u5207\uff1a\u63a5\u53e3\u5403\u7f51\u7edc\u3001\u6838\u5fc3\u5403\u4e1a\u52a1\u3001\u754c\u9762\u53ea\u5c55\u793a\u3001\u6a21\u578b\u8d2f\u7a7f\u5e76\u7528\u679a\u4e3e\u4ee3\u66ff\u9b54\u6cd5\u6570\u5b57\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u63a5\u624b\u4e00\u4e2a\u6309\u529f\u80fd\u5207\u5f97\u8fc7\u7ec6\u7684 Android \u9879\u76ee\uff1a17 \u4e2a\u6a21\u5757\u3001\u597d\u591a\u6a21\u5757\u53ea\u6709\u4e24\u4e09\u4e2a\u7c7b\uff0c\u5e94\u7528\u672c\u8eab\u6700\u591a\u4e94\u4e2a\u6a21\u5757\u5c31\u591f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[45],"tags":[78],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1312"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1312"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1312\/revisions"}],"predecessor-version":[{"id":3554,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1312\/revisions\/3554"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}