\u7f51\u9875app\u751f\u6210\u8f6f\u4ef6<\/a><\/p>\n“`<\/p>\n
\u6b65\u9aa45\uff1a\u521b\u5efaWebView<\/p>\n
\u8f6c\u5230app > src > main > res > layout > activity_main.xml\uff0c\u5e76\u5c06\u73b0\u6709\u7684\u5e03\u5c40\u66ff\u6362\u4e3aWebView\u5e03\u5c40\u3002<\/p>\n
“`<\/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
\u6b65\u9aa46\uff1a\u914d\u7f6eWebView<\/p>\n
\u5728MainActivity.java\u6587\u4ef6\u4e2d\uff0c\u5bfc\u5165\u5fc5\u8981\u7684\u7c7b\uff0c\u5e76\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230onCreate\u65b9\u6cd5\u4e2d\u3002<\/p>\n
“`<\/p>\n
\/\/ \u5bfc\u5165\u6240\u9700\u7c7b<\/p>\n
import android.webkit.WebResourceRequest;<\/p>\n
import android.webkit.WebView;<\/p>\n
import android.webkit.WebViewClient;<\/p>\n
\/\/ \u8bbe\u7f6eWebView<\/p>\n
WebView webView = findViewById(R.id.webview);<\/p>\n
webView.setWebViewClient(new MyWebViewClient());<\/p>\n
webView.getSettings().setJavaScriptEnabled(true);<\/p>\n
webView.loadUrl(“https:\/\/yourwebsite.com”);<\/p>\n
“`<\/p>\n
\u6b65\u9aa47\uff1a\u521b\u5efaWebView\u5ba2\u6237\u7aef<\/p>\n
\u5728MainActivity.java\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u5185\u90e8\u7c7bMyWebVi<\/p>\n
<\/figure>\n<\/p>\newClient\uff0c\u5b83\u5c06\u7ee7\u627fWebViewClient\u3002\u8fd9\u5c06\u786e\u4fdd\u7f51\u9875\u90fd\u52a0\u8f7d\u5230WebView\u4e2d\uff0c\u800c\u4e0d\u662f\u5728\u5916\u90e8\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00\u3002<\/p>\n
“`<\/p>\n
private static class MyWebViewClient extends WebViewClient {<\/p>\n
@Override<\/p>\n
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {<\/p>\n
view.loadUrl(request.getUrl().toString());<\/p>\n
return true;<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
\u6b65\u9aa48\uff1a\u8fd0\u884c\u548c\u6d4b\u8bd5<\/p>\n
\u5728Android\u6a21\u62df\u5668\u4e2d\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u5e76\u6d4b\u8bd5\u5176\u529f\u80fd\u3002\u5728\u53d1\u5e03\u5e94\u7528\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u8fdb\u884c\u9002\u5f53\u7684\u6027\u80fd\u548c\u8bbe\u5907\u517c\u5bb9\u6027\u6d4b\u8bd5\u3002<\/p>\n
\u6b65\u9aa49\uff1a\u751f\u6210APK\u6587\u4ef6<\/p>\n
\u5728 Android Studio \u83dc\u5355\u4e2d\uff0c\u9009\u62e9 \u201cBuild > Build Bundle(s) \/ APK(s) > Build APK(s)\u201d\u3002\u6784\u5efa\u6210\u529f\u540e\uff0cAPK\u6587\u4ef6\u5c06\u4fdd\u5b58\u5728\u9879\u76ee\u7684 build\/outputs\/apk \u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n
\u73b0\u5728\uff0c\u60a8\u5df2\u6210\u529f\u5730\u5c06\u7f51\u7ad9\u8f6c\u6362\u4e3aAPP\u5e76\u751f\u6210\u4e86APK\u6587\u4ef6\u3002\u53ef\u4ee5\u5c06\u5176\u4e0a\u4f20\u5230Google Play\u5546\u5e97\uff0c\u4e0e\u7528\u6237\u5171\u4eab\u60a8\u7684\u7f51\u7ad9\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u6807\u9898\uff1a\u5c06\u7f51\u7ad9\u8f6c\u6362\u4e3aAPP\u5e76\u751f\u6210APK\u6587\u4ef6\uff1a\u539f\u7406\u53ca\u8be6\u7ec6\u6b65\u9aa4\u6458\u8981\uff1a\u672c\u6559\u7a0b\u5c06\u5411\u60a8\u4ecb\u7ecd\u5982\u4f55\u5c06\u73b0\u6709\u7684\u7f51\u7ad9\u8f7b\u677e\u8f6c\u6362\u4e3a\u4e13\u5c5e\u7684Android\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u751f\u6210APK\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u8fd9\u4e00\u8f6c\u6362\u8fc7\u7a0b\u80cc\u540e\u7684\u57fa\u672c\u539f\u7406\uff0c<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10741,171,1066,76,10663],"class_list":["post-28028","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-html--app","tag-171","tag-1066","tag-76","tag-app-"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=28028"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28028\/revisions"}],"predecessor-version":[{"id":28222,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/28028\/revisions\/28222"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=28028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=28028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=28028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}