{"id":8836,"date":"2023-11-16T18:34:51","date_gmt":"2023-11-16T10:34:51","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=8836"},"modified":"2023-11-16T18:34:51","modified_gmt":"2023-11-16T10:34:51","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e4%b8%80%e4%b8%aa%e7%bd%91%e9%a1%b5%e6%96%87%e4%bb%b6%e7%94%9f%e6%88%90app","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/8836\/","title":{"rendered":"\u5982\u4f55\u5c06\u4e00\u4e2a\u7f51\u9875\u6587\u4ef6\u751f\u6210app?"},"content":{"rendered":"
\u5c06\u4e00\u4e2a\u7f51\u9875\u6587\u4ef6\u751f\u6210APP\u7684\u8fc7\u7a0b\u88ab\u79f0\u4e3a\u201cWeb\u89c6\u56fe\u5e94\u7528\u201d\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5c06\u4e00\u4e2a\u7f51\u9875\u5c01\u88c5\u5728\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u5e26\u4f60\u4e86\u89e3\u8fd9\u4e2a\u8fc7\u7a0b\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002\u5b9e\u9645\u4e0a\uff0c\u6709\u5f88\u591a\u5de5\u5177\u548c\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff0c\u4f46\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5Android\u548cWebView\u4e3a\u4f8b\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n
\u4e00\u3001\u539f\u7406<\/p>\n
Web\u89c6\u56fe\u5e94\u7528\u901a\u8fc7\u5c06\u7f51\u9875\u7684\u5185\u5bb9\u663e\u793a\u5728\u4e00\u4e2a\u539f\u751f\u5e94\u7528\u4e2d\uff0c\u8ba9\u4f60\u7684\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7App Store\u5b89\u88c5\u5e76\u50cf\u4f7f\u7528\u666e\u901a\u7684\u672c\u5730\u5e94\u7528\u4e00\u6837\u8bbf\u95ee\u4f60\u7684\u7f51\u7ad9\u3002\u901a\u5e38\uff0c\u8fd9\u4e9b\u5e94\u7528\u4f1a\u4f7f\u7528\u539f\u751f\u7684Web\u89c6\u56fe\u7ec4\u4ef6\uff08\u5982Android\u7684WebView\u3001iOS\u7684UIWebView\u6216WKWebView\uff09\u5728\u672c\u5730\u5e94\u7528<\/p>\n
\u4e2d\u6e32\u67d3HTML\u9875\u9762\u3002<\/p>\n \u4e8c\u3001\u8be6\u7ec6\u6b65\u9aa4<\/p>\n \u4ee5Android WebView\u4e3a\u4f8b\uff0c\u4ee5\u4e0b\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u6587\u4ef6\u751f\u6210APP\u7684\u6b65\u9aa4\uff1a<\/p>\n 1. \u73af\u5883\u642d\u5efa – \u5b89\u88c5Android Studio<\/p>\n \u9996\u5148\uff0c\u4f60\u9700\u8981\u642d\u5efa\u5f00\u53d1\u73af\u5883\u3002\u4e0b\u8f7d\u5e76\u5b89\u88c5Android Studio\uff0c\u8fd9\u662f\u4e00\u4e2a\u4e13\u7528\u4e8e\u5f00\u53d1Android\u5e94\u7528\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002<\/p>\n 2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Android\u9879\u76ee<\/p>\n \u6253\u5f00Android Studio\uff0c\u7136\u540e\u9009\u62e9\u201c\u5f00\u59cb\u65b0\u7684Android Studio\u9879\u76ee\u201d\uff0c\u4e3a\u9879\u76ee\u547d\u540d\u3001\u9009\u62e9\u9879\u76ee\u4f4d\u7f6e\u3001\u914d\u7f6e\u6a21\u677f\u7b49\uff0c\u7136\u540e\u70b9\u51fb\u201cFinish\u201d\u3002<\/p>\n 3. \u589e\u52a0Internet\u6743\u9650<\/p>\n \u4e3a\u4e86\u8ba9\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8bbf\u95ee\u7f51\u7edc\uff0c\u9700\u8981\u5728AndroidManifest.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0Internet\u6743\u9650\u3002\u5728\u6587\u4ef6\u4e2d\u7684manifest\u6807\u7b7e\u5185\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n “`<\/p>\n<\/p>\n “`<\/p>\n 4. \u6dfb\u52a0WebView\u7ec4\u4ef6<\/p>\n \u5728\u4f60\u7684\u9879\u76ee\u7684\u4e3b\u5e03\u5c40\uff08activity_main.xml\uff09\u4e2d\u6dfb\u52a0WebView\u7ec4\u4ef6\u3002\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230\u5e03\u5c40\u6587\u4ef6\u4e2d\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 5. \u914d\u7f6eWebView<\/p>\n \u5728MainActivity.java\u4e2d\uff0c\u9996\u5148\u5bfc\u5165WebView\u548cWebSettings\u7c7b\u3002\u63a5\u7740\uff0c\u5728onCreate\u65b9\u6cd5\u4e2d\uff0c\u83b7\u53d6\u521a\u521a\u6dfb\u52a0\u7684WebView\u7ec4\u4ef6\u3002\u7136\u540e\u901a\u8fc7WebSettings\u7c7b\u6765\u4fee\u6539WebView\u7684\u914d\u7f6e\u3002<\/p>\n “`java<\/p>\n import android.webkit.WebSettings;<\/p>\n import android.webkit.WebView;<\/p>\n \/\/ …<\/p>\n @Override<\/p>\n protected void onCreate(Bundle savedInstanceState) {<\/p>\n super.onCreate(savedInstanceState);<\/p>\n setContentView(R.layout.activity_main);<\/p>\n WebView webview = (WebView) findViewById(R.id.webview);<\/p>\n WebSettings webSettings = webview.getSettings();<\/p>\n webSettings.setJavaScriptEnabled(true); \/\/ \u5982\u679c\u4f60\u7684\u7f51\u9875\u4f9d\u8d56\u4e8eJavaScript\uff0c\u8bf7\u542f\u7528\u8fd9\u4e2a\u9009\u9879<\/p>\n webview.loadUrl(“https:\/\/example.com”); \/\/ \u5c06\u6b64\u5904\u7684\u7f51\u5740\u66ff\u6362\u6210\u4f60\u60f3\u8981\u663e\u793a\u7684\u7f51\u9875\u6587\u4ef6\u7684URL<\/p>\n }<\/p>\n “`<\/p>\n 6. \u914d\u7f6e\u58f0\u660e\u5468\u671f\u4e8b\u4ef6<\/p>\n \u4e3a\u9632\u6b62WebView\u5728Activity\u7684\u751f\u547d\u5468\u671f\u4e8b\u4ef6\u4e0a\u9020\u6210\u4e0d\u7a33\u5b9a\u7684\u884c\u4e3a\uff0c\u9700\u8981\u8986\u76d6Activity\u7684onBackPressed\u65b9\u6cd5\u3002\u5728MainActivity.java\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n “`java<\/p>\n @Override<\/p>\n public void onBackPressed() {<\/p>\n if (webview.canGoBack()) {<\/p>\n webview.goBack();<\/p>\n } else {<\/p>\n super.onBackPressed();<\/p>\n }<\/p>\n }<\/p>\n “`<\/p>\n 7. \u7f16\u8bd1\u548c\u8fd0\u884c<\/p>\n \u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u70b9\u51fb\u201c\u8fd0\u884c\u201d\u6309\u94ae\u542f\u52a8\u6a21\u62df\u5668\u6216\u8fde\u63a5\u771f\u5b9e\u8bbe\u5907\u8fdb\u884c\u6d4b\u8bd5\u3002\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u4f60\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u4f60\u7684\u7f51\u9875\u5728WebView\u4e2d\u663e\u793a\u51fa\u6765\u3002<\/p>\n 8. APP\u6253\u5305\u548c\u53d1\u5e03<\/p>\n \u5728\u5b8c\u6210\u6d4b\u8bd5\u548c\u8c03\u8bd5\u540e\uff0c\u4f60\u9700\u8981\u5c06\u8fd9\u4e2a\u5e94\u7528\u6253\u5305\u6210\u4e00\u4e2aAPK\u6587\u4ef6\u3002\u5728Android Studio\u4e2d\uff0c\u9009\u62e9\u201cBuild->Generate Sign\u7f51\u9875\u5c31\u53ef\u4ee5\u751f\u6210app\u7684\u8f6f\u4ef6<\/a>ed Bundle\/APK\u201d\u5e76\u9075\u5faa\u63d0\u793a\u8fdb\u884c\u64cd\u4f5c\u3002\u6700\u540e\uff0c\u4f60\u53ef\u4ee5\u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u4e0a\u4f20\u5230Google Play\uff0c\u8ba9\u7528\u6237\u53ef\u4ee5\u4e0b\u8f7d\u4f7f\u7528\u3002<\/p>\n \u4ee5\u4e0a\u5c31\u662f\u5c06\u4e00\u4e2a\u7f51\u9875\u6587\u4ef6\u751f\u6210APP\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u6839\u636e\u7f51\u9875\u7279\u70b9\u5bf9\u4ee3\u7801\u8fdb\u884c\u76f8\u5e94\u7684\u8c03\u6574\u8df3\u8f6c\u7f51\u9875app\u751f\u6210<\/a>\u3002\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":" \u5c06\u4e00\u4e2a\u7f51\u9875\u6587\u4ef6\u751f\u6210APP\u7684\u8fc7\u7a0b\u88ab\u79f0\u4e3a\u201cWeb\u89c6\u56fe\u5e94\u7528\u201d\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5c06\u4e00\u4e2a\u7f51\u9875\u5c01\u88c5\u5728\u4e00\u4e2a\u672c\u5730\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u5e26\u4f60\u4e86\u89e3\u8fd9\u4e2a\u8fc7\u7a0b\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002\u5b9e\u9645\u4e0a\uff0c\u6709\u5f88\u591a\u5de5\u5177\u548c\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff0c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[6576,16,15173,149,23],"topic":[],"class_list":["post-8836","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-wordpress-app","tag-16","tag-h5app","tag-149","tag-23"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8836","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=8836"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8836\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=8836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=8836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=8836"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=8836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<\/figure>\n<\/p>\n