{"id":17001,"date":"2024-03-01T15:31:32","date_gmt":"2024-03-01T07:31:32","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=17001"},"modified":"2024-03-01T15:31:32","modified_gmt":"2024-03-01T07:31:32","slug":"%e7%bd%91%e5%9d%80%e5%8a%a0%e5%a3%b3%e6%89%93%e5%8c%85%e6%88%90apk%e8%a6%81%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/17001\/","title":{"rendered":"\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210apk\u8981\u600e\u4e48\u5b9e\u73b0\uff1f"},"content":{"rendered":"

\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210 APK\uff08\u539f\u7406\u6216\u8be6\u7ec6\u4ecb\u7ecd\uff09<\/p>\n

\u968f\u7740\u79d1\u6280\u7684\u53d1\u5c55\uff0cAP<\/p>\n

<\/figure>\n<\/p>\n

P \u5df2\u7ecf\u6210\u4e3a\u4eba\u4eec\u65e5\u5e38\u751f\u6d3b\u4e2d\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\u3002\u9762\u5bf9\u5e7f\u6cdb\u7684\u79fb\u52a8\u7aef\u7528\u6237\uff0c\u8bb8\u591a\u7f51\u7ad9\u5e0c\u671b\u5efa\u7acb\u66f4\u52a0\u5feb\u901f\u3001\u6613\u7528\u7684\u8bbf\u95ee\u65b9\u5f0f\uff0c\u8fd9\u4f7f\u5f97\u5c06\u7f51\u5740\u5c01\u88c5\u6210 APK \u8fd9\u4e00\u6280\u672f\u5e94\u8fd0\u800c\u751f\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210 APK \u7684\u539f\u7406\u3001\u64cd\u4f5c\u6d41\u7a0b\u548c\u6ce8\u610f\u4e8b\u9879\u7b49\u3002<\/p>\n

\u4e00\u3001\u539f\u7406\u4ecb\u7ecd<\/p>\n

\u5c01\u88c5\u7f51\u5740\u6210 APK \u7684\u539f\u7406\u662f\u5c06\u7f51\u9875\u5e94\u7528 (Web Application) \u5e94\u7528\u5230\u539f\u751f\u5b89\u5353\u5e94\u7528 (Native Android Application) \u4e2d\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u5c06\u7f51\u5740\u5305\u88c5\u5728\u4e00\u4e2a\u7b80\u5355\u7684\u539f\u751f\u5b89\u5353\u5e94\u7528\u4e2d\uff0c\u5e76\u901a\u8fc7 WebView \u5c55\u793a\u76f8\u5173\u5185\u5bb9\u3002WebView \u662f\u4e00\u4e2a\u7528\u4e8e\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u663e\u793a\u7f51\u9875\u7684\u7ec4\u4ef6\uff0c\u800c\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u7528\u6237\u5c06\u4e0d\u518d\u4f7f\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u7ad9\uff0c\u800c\u662f\u5229\u7528\u4e00\u4e2a\u53ef\u76f4\u63a5\u5b89\u88c5\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u7684\u5b89\u5353\u5e94\u7528\u6765\u8bbf\u95ee\u7f51\u7ad9\u3002<\/p>\n

\u4e8c\u3001\u64cd\u4f5c\u6d41\u7a0b<\/p>\n

\u8981\u5c06\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210 APK\uff0c\u53ea\u9700\u9075\u5faa\u4ee5\u4e0b\u7b80\u5355\u7684\u6b65\u9aa4\uff1a<\/p>\n

1. \u5b89\u88c5 Android Studio\uff1a\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5 Android Studio\uff0c\u8fd9\u662f\u4e00\u4e2a\u4e13\u4e3a Android \u5e94\u7528\u5f00\u53d1\u8bbe\u8ba1\u7684\u5b98\u65b9\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002<\/p>\n

2. \u521b\u5efa\u65b0\u9879\u76ee\uff1a\u6253\u5f00 Android Studio\uff0c\u9009\u62e9 \u201cCreate New Project\u201d \u4ee5\u5f00\u59cb\u521b\u5efa\u65b0\u9879\u76ee\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u8bf7\u786e\u4fdd\u9009\u62e9 “Empty Activity” \u6a21\u677f\u3002<\/p>\n

3. \u4fee\u6539\u5e03\u5c40\u6587\u4ef6\uff1a\u627e\u5230 \u201cres\/layout\/activity_main.xml\u201d \u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4ee3\u7801\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n

“`<\/p>\n<\/p>\n

xmlns:app=”http:\/\/schemas.android.com\/apk\/res-auto”<\/p>\n

xmlns:tools=”http:\/\/schemas.android.com\/tools”<\/p>\n

android:id=”@+id\/webview”<\/p>\n

android:layout_width=”match_parent”<\/p>\n

android:layout_height=”match_parent”<\/p>\n

tools:context=”.MainActivity” \/><\/p>\n

“`<\/p>\n

\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u521b\u5efa\u4e00\u4e2a WebView \u5143\u7d20\uff0c\u4ee5\u4fbf\u5c06\u7f51\u5740\u52a0\u8f7d\u5230\u5176\u4e2d\u3002<\/p>\n

4. \u6dfb\u52a0\u7f51\u7edc\u6743\u9650\uff1a\u5728 \u201cAndroidManifest.xml\u201d \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u4ee5\u5141\u8bb8\u5e94\u7528\u8bbf\u95ee\u7f51\u7edc\uff1a<\/p>\n

“`<\/p>\n<\/p>\n

“`<\/p>\n

5. \u914d\u7f6e WebView\uff1a\u5728 \u201cMainActivity.java\u201d \u6587\u4ef6\u4e2d\uff0c\u627e\u5230 \u201conCreate()\u201d \u65b9\u6cd5\uff0c\u7136\u540e\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u914d\u7f6e WebView\uff1a<\/p>\n

a. \u5bfc\u5165 WebView \u548c WebSettings \u7c7b\uff1a<\/p>\n

“`<\/p>\n

import android.webkit.WebView;<\/p>\n

import android.webkit.WebSettings;<\/p>\n

“`<\/p>\n

b. \u5728 oncreate \u65b9\u6cd5\u4e2d\uff0c\u521d\u59cb\u5316\u5e76\u914d\u7f6e WebView\uff1a<\/p>\n

“`<\/p>\n

\u7f51\u5740\u8f6capp\u5236\u4f5c\u751f\u6210\u5668<\/a>WebView webView = (WebView) findViewById(R.id.webview);<\/p>\n

WebSettings webSettings = webView.getSettings();<\/p>\n

webSettings.setJavaScriptEnabled(true);<\/p>\n

webView.loadUrl(“https:\/\/www.example.com”);<\/p>\n

“`<\/p>\n

\u8bf7\u786e\u4fdd\u5c06 \u201chttps:\/\/www.example.com\u201d \u66ff\u6362\u4e3a\u8981\u6253\u5305\u5230 APK \u4e2d\u7684\u7f51\u5740\u3002<\/p>\n

6. \u7f16\u8bd1 APK\uff1a\u70b9\u51fb Android Studio \u4e2d\u7684\u7f16\u8bd1\u6309\u94ae\uff08\u901a\u5e38\u8868\u793a\u4e3a\u4e00\u4e2a\u7eff\u8272\u4e09\u89d2\u5f62\uff09\uff0c\u7136\u540e\u5c06\u9879\u76ee\u6253\u5305\u6210 APK\u3002<\/p>\n

\u4e09\u3001\u6ce8\u610f\u4e8b\u9879<\/p>\n

1. \u8bf7\u786e\u4fdd\u76ee\u6807\u7f51\u5740\u5728\u79fbhtml\u5c01\u88c5app\u7535\u89c6<\/a>\u52a8\u8bbe\u5907\u4e0a\u5177\u6709\u826f\u597d\u7684\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff0c\u4ee5\u4fbf\u4e3a\u7528\u6237\u63d0\u4f9b\u6700\u4f73\u7684\u6d4f\u89c8\u4f53\u9a8c\u3002<\/p>\n

2. \u4e0d\u8981\u5fd8\u8bb0\u5728 WebView \u4e2d\u542f\u7528 JavaScript \u652f\u6301\uff0c\u56e0\u4e3a\u8bb8\u591a\u7f51\u7ad9\u4f9d\u8d56 JavaScript \u6765\u5b9e\u73b0\u4ea4\u4e92\u529f\u80fd\u3002<\/p>\n

3. \u8003\u8651\u6dfb\u52a0\u989d\u5916\u7684\u529f\u80fd\uff0c\u4f8b\u5982\u7f13\u5b58\u3001\u9519\u8bef\u5904\u7406\u548c\u79bb\u7ebf\u8bbf\u95ee\u652f\u6301\uff0c\u4ee5\u63d0\u9ad8\u5e94\u7528\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n

4. \u8981\u5236\u4f5c\u53ef\u4ee5\u5728 Google Play \u5546\u5e97\u5206\u53d1\u7684\u5e94\u7528\uff0c\u8bf7\u786e\u4fdd\u9075\u5faa Google Play \u7684\u653f\u7b56\u548c\u51c6\u5219\u3002<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210 APK \u7684\u8be6\u7ec6\u4ecb\u7ecd\u548c\u64cd\u4f5c\u6d41\u7a0b\u3002\u5c3d\u7ba1\u8fd9\u662f\u4e00\u79cd\u5165\u95e8\u7ea7\u7684\u65b9\u5f0f\uff0c\u4f46\u5bf9\u4e8e\u8bb8\u591a\u4f01\u4e1a\u548c\u4e2a\u4eba\u6765\u8bf4\uff0c\u5b83\u4ecd\u7136\u662f\u4e00\u79cd\u5feb\u901f\u3001\u9ad8\u6548\u4e14\u6210\u672c\u8f83\u4f4e\u7684\u9014\u5f84\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4ed6\u4eec\u5728\u79fb\u52a8\u7aef\u63d0\u4f9b\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7f51\u5740\u52a0\u58f3\u6253\u5305\u6210 APK\uff08\u539f\u7406\u6216\u8be6\u7ec6\u4ecb\u7ecd\uff09\u968f\u7740\u79d1\u6280\u7684\u53d1\u5c55\uff0cAPP \u5df2\u7ecf\u6210\u4e3a\u4eba\u4eec\u65e5\u5e38\u751f\u6d3b\u4e2d\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\u3002\u9762\u5bf9\u5e7f\u6cdb\u7684\u79fb\u52a8\u7aef\u7528\u6237\uff0c\u8bb8\u591a\u7f51\u7ad9\u5e0c\u671b\u5efa\u7acb\u66f4\u52a0\u5feb\u901f\u3001\u6613\u7528\u7684\u8bbf\u95ee\u65b9\u5f0f\uff0c\u8fd9\u4f7f\u5f97\u5c06\u7f51\u5740\u5c01\u88c5\u6210 APK \u8fd9<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17261,20114,766,260,1196],"topic":[],"class_list":["post-17001","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-app","tag-webapp","tag-766","tag-260","tag-1196"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17001","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\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=17001"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17001\/revisions"}],"predecessor-version":[{"id":17046,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/17001\/revisions\/17046"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=17001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=17001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=17001"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=17001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}