{"id":15516,"date":"2024-01-11T18:31:27","date_gmt":"2024-01-11T10:31:27","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=15516"},"modified":"2024-01-11T18:31:27","modified_gmt":"2024-01-11T10:31:27","slug":"%e7%94%a8%e7%bd%91%e9%a1%b5%e7%94%9f%e6%88%90app%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95%e6%8e%a8%e8%8d%90","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/15516\/","title":{"rendered":"\u7528\u7f51\u9875\u751f\u6210app\u5e38\u7528\u65b9\u6cd5\u63a8\u8350"},"content":{"rendered":"
\u5982\u4f55\u7528\u7f51\u9875\u751f\u6210APP\uff1a\u539f\u7406\u4e0e\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n
\u5728\u4e92\u8054\u7f51\u6280\u672f\u65e5\u65b0\u6708\u5f02\u7684\u4eca\u5929\uff0c\u5404\u79cd\u6280\u672f\u90fd\u5728\u4ee5\u524d\u6240\u672a\u6709\u7684\u901f\u5ea6\u53d1\u5c55\u3002\u4f7f\u7528\u7f51\u9875\u751f\u6210APP\u6210\u4e3a\u8d8a\u6765\u8d8a\u591a\u5f00\u53d1\u8005\u7684\u9009\u62e9\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u7528\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4ee5\u53ca\u64cd\u4f5c\u6559\u7a0b\u3002<\/p>\n
\u4e00\u3001\u539f\u7406<\/p>\n
\u7f51\u9875\u751f\u6210APP\u7684\u5173\u952e\u6280\u672f\u662f\u57fa\u4e8eWebView\u3002WebView\u662f\u4e00\u4e2a\u5c55\u793a\u7f51\u9875\u5185\u5bb9\u7684\u7ec4\u4ef6\uff0c\u5141\u8bb8\u628a\u7f51\u9875\u5d4c\u5165\u5230APP\u4e2d\u3002\u901a\u8fc7\u8fd9\u4e2a\u539f\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7f51\u9875\u5236\u4f5c\u6210APP\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u52a0\u4f18\u8d28\u7684\u4f53\u9a8c\u3002\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n
1. \u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u5f00\u53d1\u7f51\u7ad9\uff0c\u5b9e\u73b0\u7f51\u9875\u5185\u5bb9\u5448\u73b0\u3002<\/p>\n
2. \u521b\u5efa\u4e00\u4e2a\u539f\u751fAPP\uff08Android\u6216iOS\uff09\uff0c\u5e76\u5728APP\u4e2d\u96c6\u6210WebView\u3002<\/p>\n
3. \u628a\u7f51\u9875\u7684URL\u5730\u5740\u52a0\u8f7d\u5230WebView\u4e2d\uff0c\u5b9e\u73b0\u5728APP\u5185\u67e5\u770b\u548c\u8bbf\u95ee\u7f51\u9875\u5185\u5bb9\u3002<\/p>\n
4. \u6dfb\u52a0APP\u7684\u76f8\u5173\u914d\u7f6e\uff0c\u5982\u56fe\u6807\u3001\u542f\u52a8\u753b\u9762\u3001\u6743\u9650\u7b49\uff0c\u4f18\u5316\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n
5. \u6253\u5305APP\u6587\u4ef6\uff0c\u53d1\u5e03\u5230\u5404\u5927\u5e94\u7528\u5e02\u573a\u3002<\/p>\n
\u4e8c\u3001\u8be6\u7ec6\u6559\u7a0b<\/p>\n
\u4e0b\u9762\u4ee5\u521b\u5efa\u4e00\u4e2a\u5b89\u5353APP\u4e3a\u4f8b\uff0c\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u7528\u7f51\u9875\u751f\u6210APP\u7684\u6b65\u9aa4\uff1a<\/p>\n
1. \u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n
a. \u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Android Studio\u3002<\/p>\n
b. \u642d\u5efa\u597d\u81ea\u5df1\u7684\u7f51\u7ad9\uff0c\u9700\u8981\u5c06\u8981\u5c55\u793a\u7684\u7f51\u9875\u5185\u5bb9\u90e8\u7f72\u5230\u4e00\u4e2a\u5728\u7ebf\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n
2. \u521b\u5efaAndroid\u9879\u76ee\uff1a<\/p>\n
a. \u6253\u5f00Android Studio\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Android\u9879\u76ee\u3002\u9009\u62e9”Empty Activity”\u6a21\u677f\uff0c\u8bbe\u7f6e\u597d\u9879\u76ee\u7684\u540d\u79f0\u3001\u5305\u540d\u7b49\u4fe1\u606f\uff0c\u70b9\u51fb”Finish”\u3002<\/p>\n<\/p>\n
3. \u96c6\u6210WebView\uff1a<\/p>\n
a. \u6253\u5f00\u9879\u76ee\u7684\u4e3b\u5e03\u5c40\u6587\u4ef6\uff08\u5982activity_main.xml\uff09\u3002\u4f7f\u7528WebView\u7ec4\u4ef6\u66ff\u6362\u6839\u5e03\u5c40\u4e2d\u7684\u9ed8\u8ba4TextView\u3002<\/p>\n
\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n
h5\u9875\u9762\u6253\u5305\u751f\u6210app<\/a> “`<\/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 b. \u6253\u5f00\u9879\u76ee\u7684\u4e3bActivity\u6587\u4ef6\uff08\u5982MainActivity.java\u6216MainActivity.kt\uff09\u3002\u5b9e\u4f8b\u5316WebView\u5bf9\u8c61\uff0c\u5e76\u914d\u7f6e\u76f8\u5173\u5c5e\u6027\u3002<\/p>\n \u793a\u4f8b\u4ee3\u7801\uff08Kotlin\uff09\uff1a<\/p>\n “`<\/p>\n \/\/ \u5b9e\u4f8b\u5316WebView<\/p>\n val webView = findViewById(R.id.webview)<\/p>\n \/\/ \u542f\u7528JavaScript<\/p>\n webView.settings.javaScriptEnabled = true<\/p>\n \/\/ \u8bbe\u7f6eWebViewClient\uff0c\u907f\u514d\u4f7f\u7528\u9ed8\u8ba4\u6d4f\u89c8\u5668\u6253\u5f00\u7f51\u9875<\/p>\n webView.webViewClient = object : WebViewClient() {<\/p>\n override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {<\/p>\n view.loadUrl(url)<\/p>\n return true<\/p>\n }<\/p>\n }<\/p>\n \/\/ \u52a0\u8f7d\u7f51\u9875<\/p>\n webView.loadUrl(“https:\/\/your-website-url.com”)<\/p>\n “`<\/p>\n c. \u5728AndroidManifest.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0Internet\u6743\u9650\uff1a<\/p>\n “`<\/p>\n<\/p>\n “`<\/p>\n 4. \u914d\u7f6eAPP\u4fe1\u606f\uff1a<\/p>\n a. \u4e3aAPP\u8bbe\u7f6e\u56fe\u6807\u548c\u542f\u52a8\u753b\u9762\u3002\u5c06\u56fe\u7247\u8d44\u6e90\u653e\u5165\u9879\u76ee\u7684res\u6587\u4ef6\u5939\u4e2d\uff0c\u4fee\u6539activity_main.xml\u4e2d\u7684ImageView\u548cBackground\u5c5e\u6027\u3002<\/p>\n b. \u5728AndroidManifest.xml\u4e2d\u8bbe\u7f6eAPP\u7684\u540d\u5b57\u3001\u7248\u672c\u53f7\u3001\u6743\u9650\u7b49\u4fe1\u606f\u3002<\/p>\n 5. \u6253\u5305APP\uff1a<\/p>\n a. \u5728Android Studio\u4e2d\u6267\u884cBuild > Generate Signed Bundle\/APK\u64cd\u4f5c\uff0c\u751f\u6210\u5df2\u7b7e\u540d\u7684APP\u5b89\u88c5\u5305\u3002<\/p>\n b. \u5c06\u751f\u6210\u7684\u5b89\u88c5\u5305\u4f20\u9012\u7ed9\u6d4b\u8bd5\u4eba\u5458\u6216\u53d1\u5e03\u5230Goog<\/p>\n le Play\u5546\u5e97\u3002<\/p>\n \u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u5c06\u7f51\u9875\u8f6c\u6362\u6210\u4e86\u4e00\u4e2aAPP\u3002\u867d\u7136\u8fd9\u53ea\u662f\u4e00\u4e2a\u5165\u95e8\u7ea7\u7684\u6559\u7a0b\uff0c\u4f46\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u60a8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5b66\u5728\u7ebf\u751f\u6210app\u5e73\u53f0<\/a>\u4e60\u5982\u4f55\u4f18\u5316APP\u6027\u80fd\u3001\u5b9e\u73b0\u8de8\u5e73\u53f0\u5f00\u53d1\u7b49\u9ad8\u7ea7\u6280\u5de7\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u4f18\u8d28\u7684\u79fb\u52a8\u7aef\u7f51\u7edc\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u5982\u4f55\u7528\u7f51\u9875\u751f\u6210APP\uff1a\u539f\u7406\u4e0e\u8be6\u7ec6\u4ecb\u7ecd\u5728\u4e92\u8054\u7f51\u6280\u672f\u65e5\u65b0\u6708\u5f02\u7684\u4eca\u5929\uff0c\u5404\u79cd\u6280\u672f\u90fd\u5728\u4ee5\u524d\u6240\u672a\u6709\u7684\u901f\u5ea6\u53d1\u5c55\u3002\u4f7f\u7528\u7f51\u9875\u751f\u6210APP\u6210\u4e3a\u8d8a\u6765\u8d8a\u591a\u5f00\u53d1\u8005\u7684\u9009\u62e9\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u7528\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4ee5\u53ca\u64cd\u4f5c\u6559\u7a0b\u3002\u4e00<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15176,6133,16,149,23],"topic":[],"class_list":{"0":"post-15516","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkf","7":"tag-app","9":"tag-16","10":"tag-149","11":"tag-23"},"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15516","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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=15516"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15516\/revisions"}],"predecessor-version":[{"id":15584,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/15516\/revisions\/15584"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=15516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=15516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=15516"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=15516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<\/figure>\n<\/p>\n