mac\u7f51\u7ad9\u5c01\u88c5app<\/a>iew webView = findViewById(R.id.webview);<\/p>\n“`<\/p>\n
\u7136\u540e\uff0c\u8bbe\u7f6e WebView \u7684\u4e00\u4e9b\u5c5e\u6027\u548c\u914d\u7f6e\uff0c\u5141\u8bb8 JavaScript\u3001\u7f29\u653e\u7b49\u529f\u80fd\uff1a<\/p>\n
“`java<\/p>\n
WebSettings webSettings = webView.getSettings();<\/p>\n
webSettings.setJavaScriptEnabled(true);<\/p>\n
webSettings.setBuiltInZoomControls(true);<\/p>\n
webSettings.setDisplayZoomControls(false);<\/p>\n
“`<\/p>\n
\u6700\u540e\uff0c\u52a0\u8f7d\u4f60\u7684\u7f51\u9875 URL\uff08\u5982 “http:\/\/www.example.com”\uff09\uff1a<\/p>\n
“`java<\/p>\n
webView.loadUrl(“http:\/\/www.example.com”);<\/p>\n
“`<\/p>\n
e. \u5904\u7406\u7f51\u9875\u5bfc\u822a<\/p>\n
\u4e3a\u4e86\u8ba9 WebView \u80fd\u591f\u5904\u7406\u7f51\u9875\u7684\u5bfc\u822a\uff08\u5982\u524d\u8fdb\u3001\u540e\u9000\u3001\u5237\u65b0\u7b49\uff09\uff0c\u8fd8\u9700\u8981\u5904\u7406\u4e00\u4e9b WebView \u4e8b\u4ef6\u3002\u4f8b\u5982\uff0c\u91cd\u5199 `onBackPressed()` \u65b9\u6cd5\uff0c\u5904\u7406\u70b9\u51fb\u8bbe\u5907\u7684\u201c\u8fd4\u56de\u201d\u6309\u94ae\u65f6\u7684\u7f51\u9875\u5bfc\u822a\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
f. \u7f16\u8bd1\u548c\u8fd0\u884c App<\/p>\n
\u5728 Android Studio \u4e2d\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\uff0c\u5c06 App \u5b89\u88c5\u5230\u4f60\u7684 Android \u8bbe\u5907\u4e0a\u3002\u4f60\u4f1a\u770b\u5230\u7f51\u9875\u4ee5\u539f\u751f App \u7684\u5f62\u5f0f\u5448\u73b0\u5728\u8bbe\u5907\u4e0a\u3002\u81f3\u6b64\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u5c06\u7f51\u9875\u6253\u5305\u6210\u4e86 Android App\u3002<\/p>\n
3. \u4f7f\u7528\u6846\u67b6\u7b80\u5316\u5f00\u53d1<\/p>\n
\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u73b0\u6709\u7684\u6846\u67b6\u548c\u5e93\u7b80\u5316\u7f51\u9875\u6253\u5305\u6210 Android App \u7684\u8fc7\u7a0b\u3002\u4f8b\u5982\uff0cPhoneGap \/ Apache Cordova\u3001Ionic \u7b49\u6846\u67b6\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u539f\u751f\u5e94\u7528\u3002\u8fd9\u4e9b\u6846\u67b6\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4e30\u5bcc\u7684\u63d2\u4ef6\u548c API\uff0c\u8ba9\u4f60\u53ef\u4ee5\u5728 Android \u548c iOS \u7b49\u5e73\u53f0\u4e0a\u90e8\u7f72\u4f60\u7684 Web \u5e94\u7528\u7a0b\u5e8f\uff0c\u540c\u65f6\u8c03\u7528\u5404\u79cd\u8bbe\u5907\u529f\u80fd\uff08\u5982\u6444\u50cf\u5934\u3001\u5730\u7406\u4f4d\u7f6e\u3001\u901a\u8baf\u5f55\u7b49\uff09\u3002<\/p>\n
\u603b\u7ed3<\/p>\n
\u5c06\u7f51\u9875\u6253\u5305\u6210 Android App \u662f\u4e00\u79cd\u7b80\u5355\u6613\u884c\u7684\u65b9\u6cd5\uff0c\u8ba9 Web \u5f00\u53d1\u8005\u5728\u65e0\u9700\u6df1\u5165\u6df1\u5165\u539f\u751f\u5f00\u53d1\u7684\u60c5\u51b5\u4e0b\u6784\u5efa\u79fb\u52a8\u5e94\u7528\u3002\u901a\u8fc7 WebView \u7ec4\u4ef6\u548c\u76f8\u5173\u6280\u672f\uff0c\u4f60\u53ef\u4ee5\u5c06\u7f51\u9875\u5185\u5bb9\u5c01\u88c5\u4e3a\u5b89\u5353\u5e94\u7528\uff0c\u5b9e\u73b0\u8de8\u5e73\u53f0\u7684 Web \u5e94\u7528\u3002\u501f\u52a9\u4e00\u4e9b\u6210\u719f\u7684\u6846\u67b6\u548c\u5de5\u5177\uff0c\u4f60\u8fd8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7b80\u5316\u5f00\u53d1\u8fc7\u7a0b\u548c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u7f51\u9875\u6253\u5305\u6210 Android App\uff08\u8be6\u7ec6\u4ecb\u7ecd\uff09\u968f\u7740\u4e92\u8054\u7f51\u7684\u5feb\u901f\u53d1\u5c55\uff0c\u79fb\u52a8\u8bbe\u5907\u5df2\u7ecf\u6210\u4e3a\u4e86\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\u3002\u667a\u80fd\u624b\u673a\u548c\u5e73\u677f\u7535\u8111\u4e0d\u4ec5\u4f7f\u6211\u4eec\u968f\u65f6\u968f\u5730\u83b7\u53d6\u4fe1\u606f\u3001\u4eab\u53d7\u4fbf\u6377\u7684\u7f51\u7edc\u670d\u52a1\uff0c\u66f4\u8ba9\u5f00\u53d1\u8005\u6709\u4e86\u66f4\u591a<\/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":[17657,384,10599,736,149],"topic":[],"class_list":["post-24119","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-h5app","tag-384","tag-app","tag-736","tag-149"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24119","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=24119"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24119\/revisions"}],"predecessor-version":[{"id":24141,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24119\/revisions\/24141"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=24119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=24119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=24119"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=24119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}