{"id":17620,"date":"2024-01-08T11:59:21","date_gmt":"2024-01-08T03:59:21","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=17620"},"modified":"2024-01-08T11:59:21","modified_gmt":"2024-01-08T03:59:21","slug":"android%e7%bd%91%e9%a1%b5%e5%bc%80%e5%8f%91%e6%9c%89%e4%bb%80%e4%b9%88%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2024\/appkfa\/17620\/","title":{"rendered":"android\u7f51\u9875\u5f00\u53d1\u6709\u4ec0\u4e48\u529e\u6cd5"},"content":{"rendered":"<p>Android\u7f51\u9875\u5f00\u53d1\u662f\u6307\u5728Android\u5e73\u53f0\u4e0a\u5f00\u53d1\u548c\u8bbe\u8ba1\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\u5305\u62ec\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u5f00\u53d1\u7f51\u9875\uff0c\u4ee5\u53ca\u4f7f\u7528Android SDK\u548cJava\u7b49\u6280\u672f\u5c06\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u96c6\u6210\u5230Android\u5e73\u53f0\u4e0a\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdAndroid\u7f51\u9875\u5f00\u53d1\u7684\u539f\u7406\u548c\u6b65\u9aa4\u3002<\/p>\n<p>\u4e00\u3001Android\u7f51\u9875\u5f00\u53d1\u7684\u539f\u7406<\/p>\n<p>Android\u7f51\u9875\u5f00\u53d1\u7684\u539f\u7406\u662f\u5c06\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u5d4c\u5165\u5230Android\u5e73\u53f0\u7684WebView\u63a7\u4ef6\u4e2d\u3002WebView\u662fAndroid\u63d0\u4f9b\u7684\u4e00\u4e2a\u63a7\u4ef6\uff0c\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u5185\u90e8\u663e\u793a\u7f51\u9875\u5185\u5bb9\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528WebView\u63a7\u4ef6\u6765\u52a0\u8f7d\u672c\u5730\u6216\u8fdc\u7a0b\u7684\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u663e\u793a\u3002<\/p>\n<p>\u5728Android\u5e73\u53f0\u4e0a\u5f00\u53d1\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u6765\u5f00\u53d1\u7f51\u9875\u3002\u7136\u540e\uff0c\u4f7f\u7528WebView\u63a7\u4ef6\u5c06\u7f51\u9875\u52a0\u8f7d\u5230Android\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Java\u4ee3\u7801\u6765\u63a7\u5236WebView\u63a7\u4ef6\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u52a0\u8f7d\u7f51\u9875\u3001\u63a7\u5236\u9875\u9762\u6eda\u52a8\u3001\u5904\u7406\u7528\u6237\u8f93\u5165\u7b49\u3002<\/p>\n<p>\u4e8c\u3001Android\u7f51\u9875\u5f00\u53d1\u7684\u6b65\u9aa4<\/p>\n<p>\u4ee5\u4e0b\u662fAndroid\u7f51\u9875\u5f00\u53d1\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<p>1.\u521b\u5efa\u7f51\u9875<\/p>\n<p>\u9996\u5148\uff0c\u5f00\u53d1\u8005\u9700\u8981\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u6765\u521b\u5efa\u7f51\u9875\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6765\u7f16\u5199\u7f51\u9875\u4ee3\u7801\u3002\u5728\u7f16\u5199\u7f51\u9875\u4ee3\u7801\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u7f51\u9875\u7684\u5e03\u5c40\u3001\u6837\u5f0f\u548c\u4ea4\u4e92\u884c\u4e3a\u7b49\u65b9\u9762\u3002<\/p>\n<p>2.\u5c06\u7f51\u9875\u5d4c\u5165\u5230WebView\u63a7\u4ef6\u4e2d<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5f00\u53d1\u8005\u9700\u8981\u5728Android\u5e94\u7528\u7a0b\u5e8f\u4e2d\u521b\u5efa\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u5e76\u5c06\u7f51\u9875\u5d4c\u5165\u5230\u8be5\u63a7\u4ef6\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u521b\u5efaWebView\u63a7\u4ef6\uff1a<\/p>\n<p>WebView webView = new WebView(context);<\/p>\n<p>\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u7f51\u9875\u52a0\u8f7d\u5230WebView\u63a7\u4ef6\u4e2d\uff1a<\/p>\n<p>webView.loadUrl(&#8220;http:\/\/www.example.com&#8221;);<\/p>\n<p>\u5176\u4e2d\uff0chttp:\/\/www.example.com\u662f\u8981\u52a0\u8f7d\u7684\u7f51\u9875\u5730\u5740\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5c06\u7f51\u9875\u5730\u5740\u66ff\u6362\u4e3a\u672c\u5730\u6216\u8fdc\u7a0b\u7684\u7f51\u9875\u5730\u5740\u3002<\/p>\n<p>3.\u5904\u7406WebV<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-04\/03\/17\/17876093895.jpg\" \/><\/figure>\n<\/p>\n<p>iew\u63a7\u4ef6\u7684\u4e8b\u4ef6<\/p>\n<p>\u5728\u5c06\u7f51\u9875\u52a0\u8f7d\u5230WebView\u63a7\u4ef6\u540e\uff0c\u5f00\u53d1\u8005\u9700\u8981\u5904\u7406WebView\u63a7\u4ef6\u7684\u4e8b\u4ef6\uff0c\u4f8b\u5982\u9875\u9762\u6eda\u52a8\u3001\u7528\u6237\u8f93\u5165\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u5904\u7406WebView\u63a7\u4ef6\u7684\u4e8b\u4ef6\uff1a<\/p>\n<p>webView.setWebViewClient(new WebViewClient() {<\/p>\n<p>    @Override<\/p>\n<p>    public boolean shouldOverrideUrlLoading(WebView view, String url) {<\/p>\n<p>        view.loadUrl(url);<\/p>\n<p>        return true;<\/p>\n<p>    }<\/p>\n<p>});<\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cshouldOverrideUrlLoading\u65b9\u6cd5\u7528\u4e8e\u5904\u7406WebView\u63a7\u4ef6\u7684URL\u52a0\u8f7d\u4e8b\u4ef6\u3002<a href=\"https:\/\/www.yimenapp.net\/dabao-2848.html\">ios\u5c01\u88c5h5\u6253\u5305<\/a>\u8be5\u65b9\u6cd5\u4f1a\u5728WebView\u63a7\u4ef6\u52a0\u8f7dURL\u65f6\u88ab\u8c03\u7528\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u8be5\u65b9\u6cd5\u4e2d\u5904\u7406URL\u52a0\u8f7d\u4e8b\u4ef6\uff0c\u5e76\u8fd4\u56detrue\u8868\u793a\u5df2\u7ecf\u5904\u7406\u4e86\u8be5\u4e8b\u4ef6\u3002<\/p>\n<p>4.\u6dfb\u52a0WebView\u63a7\u4ef6\u5230\u5e03\u5c40\u4e2d<\/p>\n<p>\u6700\u540e\uff0c\u5f00\u53d1\u8005<a href=\"https:\/\/www.yimenapp.net\/dabao-4215.html\">androidvue\u6df7\u5408\u5f00\u53d1<\/a>\u9700\u8981\u5c06WebView\u63a7\u4ef6\u6dfb\u52a0\u5230Android\u5e94\u7528\u7a0b\u5e8f\u7684\u5e03\u5c40\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06WebView\u63a7\u4ef6\u6dfb\u52a0\u5230\u5e03\u5c40\u4e2d\uff1a<\/p>\n<p>LinearLayout layout = new LinearLayout(context);<\/p>\n<p>layout.addView(webView);<\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cLinearLayout\u662f\u4e00\u4e2aAndroid\u5e03\u5c40\u63a7\u4ef6\uff0c\u7528\u4e8e\u5c06\u5176\u4ed6\u63a7\u4ef6\u6392\u5217\u5728\u4e00\u884c\u6216\u4e00\u5217\u4e2d\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u5e03\u5c40\u63a7\u4ef6\u6765\u6392\u5217WebView\u63a7\u4ef6\u548c\u5176\u4ed6\u63a7\u4ef6\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>Android\u7f51\u9875\u5f00\u53d1\u662f\u5728Android\u5e73\u53f0\u4e0a\u5f00\u53d1\u548c\u8bbe\u8ba1\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u5f00\u53d1\u8005\u9700\u8981\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u6765\u521b\u5efa\u7f51\u9875\uff0c\u5e76\u4f7f\u7528WebView\u63a7\u4ef6\u5c06\u7f51\u9875\u52a0\u8f7d\u5230Android\u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002\u5f00\u53d1\u8005\u8fd8\u9700\u8981\u5904\u7406WebView\u63a7\u4ef6\u7684\u4e8b\u4ef6\uff0c\u5e76\u5c06WebView\u63a7\u4ef6\u6dfb\u52a0\u5230Android\u5e94\u7528\u7a0b\u5e8f\u7684\u5e03\u5c40\u4e2d\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u5728Android\u5e73\u53f0\u4e0a\u5f00\u53d1\u548c\u8bbe\u8ba1\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android\u7f51\u9875\u5f00\u53d1\u662f\u6307\u5728Android\u5e73\u53f0\u4e0a\u5f00\u53d1\u548c\u8bbe\u8ba1\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\u5305\u62ec\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49\u6280\u672f\u5f00\u53d1\u7f51\u9875\uff0c\u4ee5\u53ca\u4f7f\u7528Android SDK\u548cJava\u7b49\u6280\u672f\u5c06\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[22446,10265,13,412,206],"topic":[],"class_list":["post-17620","post","type-post","status-publish","format-standard","hentry","category-appkfa","tag-app-android","tag-vue-h5apk","tag-13","tag-412","tag-206"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/17620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=17620"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/17620\/revisions"}],"predecessor-version":[{"id":17666,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/17620\/revisions\/17666"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=17620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=17620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=17620"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=17620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}