{"id":19726,"date":"2024-03-26T15:31:22","date_gmt":"2024-03-26T07:31:22","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=19726"},"modified":"2024-03-26T15:31:22","modified_gmt":"2024-03-26T07:31:22","slug":"%e7%bd%91%e7%ab%99%e6%89%93%e5%8c%85%e6%88%90%e5%ae%89%e5%8d%93app%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/19726\/","title":{"rendered":"\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353app\u64cd\u4f5c\u6d41\u7a0b\u4ecb\u7ecd"},"content":{"rendered":"

\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\uff1a\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n

\u968f\u7740\u667a\u80fd\u624b\u673a\u7684\u666e\u53ca\u548c\u79fb\u52a8\u4e92\u8054\u7f51\u7684\u5feb\u901f\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5e0c\u671b\u5411\u7528\u6237\u63d0\u4f9b\u4fbf\u6377\u7684APP\u670d\u52a1\u3002\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u662f\u4e00\u79cd\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6709\u6548\u9014\u5f84\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u539f\u7406\u53ca\u5b9e\u73b0\u6b65\u9aa4\u3002<\/p>\n

\u4e00\u3001\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u539f\u7406<\/p>\n

\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u6838\u5fc3\u539f\u7406\u662f\u5c06\u7f51\u7ad9\u5d4c\u5165\u5230\u4e00\u4e2a\u539f\u751f\u7684\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u5176\u53ef\u4ee5\u5728\u5b89\u5353\u8bbe\u5907\u4e0a\u72ec\u7acb\u8fd0\u884c\u3002\u8fd9\u901a\u5e38\u901a\u8fc7\u4f7f\u7528WebView\u7ec4\u4ef6\u5b9e\u73b0\uff0cWebView\u662f\u4e00\u79cd\u5b89apk\u5c01\u5305\u5728\u7ebf<\/a>\u5353\u4e2d\u7684\u5185\u7f6e\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u52a0\u8f7d\u548c\u663e\u793a\u7f51\u9875\u5185\u5bb9\u3002<\/p>\n

WebView\u7ec4\u4ef6\u53ef\u4ee5\u5c06\u7f51\u7ad9\u5185\u5bb9\u5d4c\u5165\u5230\u5b89\u5353APP\u4e2d\uff0c\u4f7f\u7f51\u7ad9\u5728APP\u5185\u90e8\u5448\u73b0\uff0c\u5e76\u4fdd\u6301\u539f\u7f51\u7ad9\u7684\u4ea4\u4e92<\/p>\n

<\/figure>\n<\/p>\n

\u529f\u80fd\u548c\u5916\u89c2\u3002\u8fd9\u79cd\u65b9\u6cd5\u5728\u4fdd\u6301\u7f51\u7ad9\u539f\u59cb\u8bbe\u8ba1\u548c\u529f\u80fd\u7684\u540c\u65f6\uff0c\u4f7f\u7528\u6237\u53ef\u4ee5\u5728\u5b89\u5353\u8bbe\u5907\u4e0a\u83b7\u5f97\u4e0e\u5728\u6d4f\u89c8\u5668\u4e2d\u76f8\u540c\u7684\u4f53\u9a8c\u3002<\/p>\n

\u4e8c\u3001\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u8be6\u7ec6\u5b9e\u73b0\u6b65\u9aa4<\/p>\n

\u4ee5\u4e0b\u662f\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u7b80\u8981\u5b9e\u73b0\u6b65\u9aa4\uff0c\u4f9b\u521d\u5b66\u8005\u53c2\u8003\uff1a<\/p>\n

1. \u5b89\u88c5Android Studio<\/p>\n

Android Studio\u662f\u8c37\u6b4c\u5b98\u65b9\u63a8\u8350\u7684\u5b89\u5353\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u7528\u4e8e\u521b\u5efa\u3001\u8c03\u8bd5\u548c\u6784\u5efa\u5b89\u5353\u5e94\u7528\u7a0b\u5e8f\u3002\u9996\u5148\uff0c\u8bbf\u95ee\u5b98\u65b9\u7f51\u7ad9(https:\/\/developer.android.com\/studio\/index.html)\u4e0b\u8f7d\u5e76\u5b89\u88c5Android Studio\u3002<\/p>\n

2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b89\u5353\u9879\u76ee<\/p>\n

\u5b89\u88c5\u597dAndroid Studio\u540e\uff0c\u542f\u52a8\u7a0b\u5e8f\u5e76\u9009\u62e9\u201cCreate New Project\u201d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b89\u5353\u9879\u76ee\u3002\u8bbe\u7f6e\u9879\u76ee\u540d\u79f0\u3001\u6587\u4ef6\u4fdd\u5b58\u4f4d\u7f6e\u3001\u5305\u540d\u7b49\u4fe1\u606f\u3002\u5728\u201cSelect the form factors your app will run on\u201d\u4e2d\u9009\u62e9\u201cPhone and Tablet\u201d\uff0c\u5e76\u9009\u62e9\u9002\u5f53\u7684\u6700\u4f4eAPI\u7ea7\u522b\u3002\u63a5\u4e0b\u6765\uff0c\u9009\u62e9\u201cEmpty Activity\u201d\u4f5c\u4e3a\u521d\u59cb\u6a21\u677f\uff0c\u7136\u540e\u70b9\u51fb\u201cFinish\u201d\u3002<\/p>\n

3. \u6dfb\u52a0WebView\u63a7\u4ef6<\/p>\n

\u542f\u52a8\u9879\u76ee\u540e\uff0c\u5728\u201capp > res > layout\u201d\u76ee\u5f55\u4e0b\u627e\u5230\u4f60\u7684activity\u7684XML\u5e03\u5c40\u6587\u4ef6\u3002\u4fee\u6539XML\u5e03\u5c40\u6587\u4ef6\uff0c\u6dfb\u52a0WebView\u63a7\u4ef6\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/webview”<\/p>\n

android:layout_width=”match_parent”<\/p>\n

android:layout_height=”match_parent” \/><\/p>\n

“`<\/p>\n

4. \u52a0\u8f7d\u7f51\u7ad9<\/p>\n

\u5728\u201capp > java > your-package-name\u201d\u76ee\u5f55\u4e0b\u627e\u5230\u521a\u624d\u521b\u5efa\u7684activity\u7684JAVA\u6587\u4ef6\u3002\u5728\u8be5\u6587\u4ef6\u4e2d\uff0c\u9996\u5148\u5bfc\u5165\u5fc5\u8981\u5e93\uff0c\u5e76\u5728onCreate\u65b9\u6cd5\u4e2d\u52a0\u8f7d\u4f60\u60f3\u8981\u5c55\u793a\u7684\u7f51\u5740\uff1a<\/p>\n

“`java<\/p>\n

import android.webkit.WebView;<\/p>\n

import android.webkit.WebViewClient;<\/p>\n

…<\/p>\n

\/\/ \u5728onCreate\u65b9\u6cd5\u4e2d<\/p>\n

WebView webView = (WebView) findViewById(R.id.webview);<\/p>\n

webView.setWebViewClient(new WebViewClient());<\/p>\n

webView.getSettings().setJavaScriptEnabled(true);<\/p>\n

webView.loadUrl(“https:\/\/example.com”);<\/p>\n

“`<\/p>\n

5. \u5904\u7406\u7f51\u7edc\u72b6\u6001<\/p>\n

\u4e3a\u786e\u4fddAPP\u5728\u65e0\u7f51\u7edc\u72b6\u6001\u4e0b\u4e0d\u4f1a\u5d29\u6e83\uff0c\u5728AndroidManifeshtml\u5c01\u88c5\u6210apk<\/a>t.xml\u4e2d\u6dfb\u52a0\u5982\u4e0b\u6743\u9650\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

“`<\/p>\n

6. \u7f16\u8bd1\u548c\u6253\u5305APP<\/p>\n

\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u4f60\u53ef\u4ee5\u5728Android Studio\u4e2d\u70b9\u51fb\u201cRun\u201d\uff0c\u9009\u62e9\u9002\u5f53\u7684\u76ee\u6807\u8bbe\u5907\uff0c\u5728\u8bbe\u5907\u4e0a\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6700\u540e\u5728Android Studio\u4e2d\u9009\u62e9\u201cBuild > Generate Signed APK\u201d\uff0c\u6839\u636e\u63d0\u793a\u751f\u6210\u7b7e\u540d\u8bc1\u4e66\uff0c\u751f\u6210\u6700\u7ec8\u7684APK\u5b89\u88c5\u5305\u3002<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u5730\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u4e86\u4e00\u4e2a\u5b89\u5353APP\uff0c\u53ef\u4ee5\u53d1\u5e03\u5230\u5e94\u7528\u5546\u5e97\u6216\u8005\u76f4\u63a5\u5206\u4eab\u7ed9\u4f60\u7684\u7528\u6237\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u7684\u539f\u7406\u53ca\u5b9e\u73b0\u6b65\u9aa4\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u7b80\u4fbf\uff0c\u4f46\u53ef\u80fd\u4e0d\u9002\u7528\u4e8e\u6240\u6709\u7c7b\u578b\u7684\u7f51\u7ad9\u3002\u5bf9\u4e8e\u9ad8\u5ea6\u5b9a\u5236\u5316\u548c\u4ea4\u4e92\u6027\u5f3a\u7684\u7f51\u7ad9\uff0c\u5f00\u53d1\u539f\u751fAPP\u6216\u4f7f\u7528\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6(\u5982React Native\u3001Flutter)\u53ef\u80fd\u66f4\u5408\u9002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\uff1a\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u968f\u7740\u667a\u80fd\u624b\u673a\u7684\u666e\u53ca\u548c\u79fb\u52a8\u4e92\u8054\u7f51\u7684\u5feb\u901f\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5e0c\u671b\u5411\u7528\u6237\u63d0\u4f9b\u4fbf\u6377\u7684APP\u670d\u52a1\u3002\u5c06\u7f51\u7ad9\u6253\u5305\u6210\u5b89\u5353APP\u662f\u4e00\u79cd\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6709\u6548\u9014\u5f84\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5c06\u7f51\u7ad9\u6253<\/p>\n","protected":false},"author":23,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[766,797,247,18243,16275],"topic":[],"class_list":["post-19726","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-766","tag-797","tag-247","tag-app"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=19726"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19726\/revisions"}],"predecessor-version":[{"id":19760,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19726\/revisions\/19760"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=19726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=19726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=19726"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=19726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}