{"id":4114,"date":"2023-05-05T18:42:54","date_gmt":"2023-05-05T10:42:54","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=4114"},"modified":"2023-05-05T18:42:54","modified_gmt":"2023-05-05T10:42:54","slug":"autojs%e5%a6%82%e4%bd%95%e5%b0%86%e7%bd%91%e9%a1%b5%e7%94%9f%e6%88%90app%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/4114.html","title":{"rendered":"autojs\u5982\u4f55\u5c06\u7f51\u9875\u751f\u6210app\uff1f"},"content":{"rendered":"<p>AutoJS\u662f\u4e00\u4e2a\u57fa\u4e8eJavaScript\u7684Android\u81ea\u52a8\u5316\u7f16\u5199\u53ca\u6267\u884c\u5e73\u53f0\uff0c\u4e3b\u8981\u7528\u4e8eAndroid\u8bbe\u5907\u7684\u81ea\u52a8\u5316\u8fd0\u884c\u811a\u672c\u3002\u7136\u800c\uff0c\u5b83\u4e0d\u76f4\u63a5\u5c06\u7f51\u9875\u8f6c\u6362\u4e3aAndroid APP\u3002\u8981\u5c06\u7f51\u9875\u8f6c\u6362\u4e3aAPP\uff0c\u53ef\u4ee5\u4f7f\u7528Webview\u6280\u672f\u548c\u539f\u751fAPP\u6846\u67b6\u3002\u4e0b\u9762\u662f\u5c06\u7f51\u9875\u751f\u6210A<a href=\"http:\/\/www.yimenyun.cn\/app-shengcheng-56.html\">\u7f51\u9875\u5982\u4f55\u751f\u6210app\u56fe\u6807<\/a>PP\u7684\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<p>\u539f\u7406\uff1a<\/p>\n<p>\u5728\u539f\u751fAndroid\u5e94\u7528\u4e2d\uff0c\u5f15\u5165WebView\u7ec4\u4ef6\uff0c\u5c06\u9700\u8981\u663e\u793a\u7684\u7f51\u9875\u52a0\u8f7d\u5230\u8be5\u7ec4\u4ef6\u4e2d\u3002\u8fd9\u6837\uff0c\u4f60\u53ef\u4ee5\u5c06\u4efb\u4f55\u7f51\u9875\u5c01\u88c5\u5230\u539f\u751f\u5e94\u7528\u4e2d\uff0c\u5e76\u63d0\u4f9b\u7ed9\u7528\u6237\u4f7f\u7528\u3002\u4efb\u4f55\u65f6\u5019\u7f51\u9875\u5185\u5bb9\u66f4\u65b0\uff0c\u539f\u751f\u5e94\u7528\u4e5f\u4f1a\u540c\u6b65\u66f4\u65b0\uff0c\u65e0\u9700\u66f4\u65b0\u5e94\u7528\u672c\u8eab\u3002\u8fd9\u79cd\u6280\u672f\u5141\u8bb8\u5728\u4e00\u4e2a\u539f\u751f\u5e94\u7528\u4e2d\u5c55\u793a\u7f51\u9875\u5185\u5bb9\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5feb\u901f\u5730\u5f00\u53d1\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u3002<\/p>\n<p>\u8be6\u7ec6\u4ecb\u7ecd\uff1a<\/p>\n<p>1. \u786e\u4fdd\u4f60\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u4e86Android\u5f00\u53d1IDE\uff08\u5982Android Studio\uff09\u53ca\u76f8\u5e94\u7684SDK\u3002<\/p>\n<p>2. \u5728Android Studio\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee\u3002\u9009\u62e9\u7a7a\u767dActivity\u3002<\/p>\n<p>3. \u6253\u5f00\u9879\u76ee\u4e2d\u7684\u5e03\u5c40XML\u6587\u4ef6\uff08\u5982activity_main.xml\uff09\uff0c\u627e\u5230\u76f8\u5bf9\u5e94\u7684Layout\uff08\u901a\u5e38\u662fConstraintLayout\u6216LinearLayout\uff09\uff0c\u5e76\u6dfb\u52a0WebView\u7ec4\u4ef6\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4fee\u6539activity_main.xml\u6587\u4ef6\uff0c\u6dfb\u52a0WebView\uff1a<\/p>\n<p>&#8220;`xml<\/p>\n<\/p>\n<p>    xmlns:app=&#8221;http:\/\/schemas.android.com\/apk\/res-auto&#8221;<\/p>\n<p>    android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>    android:layout_height=&#8221;match_parent&#8221;<\/p>\n<p>    android:orientation=&#8221;vertical&#8221;&gt;<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/myWebView&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;match_parent&#8221; \/&gt;<\/p>\n<p><p>&#8220;`<\/p>\n<p>4. \u5728\u5bf9\u5e94\u7684Java\u6587\u4ef6\uff08\u5982MainActivity.java\uff09\u4e2d\u627e\u5230onCreate\u65b9\u6cd5\uff0c\u4fee\u6539\u4ee3\u7801\uff0c\u52a0\u8f7d\u7f51\u9875\u3002<\/p>\n<p>&#8220;`java<\/p>\n<p>package com.example.webviewapp;<\/p>\n<p>import androidx.appcompat.app.AppCompatActivity;<\/p>\n<p>import android.os.Bundle;<\/p>\n<p>import android.webkit.WebSettings;<\/p>\n<p>import android.webkit.WebView;<\/p>\n<p>import android.webkit.WebViewClient;<\/p>\n<p>public class MainActivity extends AppCompatActivity {<\/p>\n<p>    private WebView myWebView;<\/p>\n<p>    @Override<\/p>\n<p>    protected void onCreate(Bundle savedInstanceState) {<\/p>\n<p>        super.onCreate(savedInstanceState);<\/p>\n<p>        setContent<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-01\/06\/10\/14163148014.jpg\" \/><\/figure>\n<\/p>\n<p>View(R.layout.activity_main);<\/p>\n<p>        \/\/ Find WebView by id<\/p>\n<p>        myWebView<a href=\"http:\/\/www.yimenyun.cn\/app-shengcheng-50.html\">\u7f51\u9875\u5728\u7ebf\u4e00\u952e\u751f\u6210app<\/a> = (WebView)findViewById(R.id.myWebView);<\/p>\n<p>        WebSettings webSettings = myWebView.getSettings();<\/p>\n<p>        \/\/ Enable JavaScript<\/p>\n<p>        webSettings.setJavaScriptEnabled(true);<\/p>\n<p>        \/\/ Load website<\/p>\n<p>        myWebView.loadUrl(&#8220;https:\/\/www.example.com&#8221;);<\/p>\n<p>        \/\/ Set WebView client<\/p>\n<p>        myWebView.setWebViewClient(new WebViewClient());<\/p>\n<p>    }<\/p>\n<p>    \/\/ Handle back button on WebView<\/p>\n<p>    @Override<\/p>\n<p>    public void onBackPressed() {<\/p>\n<p>        if (myWebView.canGoBack()) {<\/p>\n<p>            myWebView.goBack();<\/p>\n<p>        } else {<\/p>\n<p>            super.onBackPressed();<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u66f4\u65b0AndroidManifest.xml\uff0c\u6dfb\u52a0\u4e92\u8054\u7f51\u6743\u9650\u3002<\/p>\n<p>&#8220;`xml<\/p>\n<\/p>\n<p>    package=&#8221;com.example.webviewapp&#8221;&gt;<\/p>\n<\/p>\n<p>    &#8230;<\/p>\n<p><p>&#8220;`<\/p>\n<p>6. \u7f16\u8bd1\u5e76\u8fd0\u884c\u4f60\u7684\u5e94\u7528\u3002\u73b0\u5728\uff0c\u4f60\u5df2\u7ecf\u5c06\u7f51\u9875\u5c01\u88c5\u5230\u4e86\u4e00\u4e2aAndroid\u5e94\u7528\u4e2d\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c AutoJS \u662f\u504f\u5411\u4e8e\u4f7f\u7528 JavaScript \u8fdb\u884c\u81ea\u52a8\u5316\u800c\u975e\u521b\u5efa\u5b8c\u6574\u7684APP\u3002\u4e3a\u4e86\u5c06\u7f51\u9875\u8f6c\u5316\u4e3aAPP\uff0c\u4e0a\u8ff0Webview\u6280\u672f\u4f1a\u66f4\u9002\u5408\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AutoJS\u662f\u4e00\u4e2a\u57fa\u4e8eJavaScript\u7684Android\u81ea\u52a8\u5316\u7f16\u5199\u53ca\u6267\u884c\u5e73\u53f0\uff0c\u4e3b\u8981\u7528\u4e8eAndroid\u8bbe\u5907\u7684\u81ea\u52a8\u5316\u8fd0\u884c\u811a\u672c\u3002\u7136\u800c\uff0c\u5b83\u4e0d\u76f4\u63a5\u5c06\u7f51\u9875\u8f6c\u6362\u4e3aAndroid APP\u3002\u8981\u5c06\u7f51\u9875\u8f6c\u6362\u4e3aAPP\uff0c\u53ef<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[5262,4873,2892,1014,1409],"class_list":["post-4114","post","type-post","status-publish","format-standard","hentry","category-appshangjia","tag-app","tag-phpapp","tag-2892","tag-1014","tag-1409"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/4114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=4114"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/4114\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=4114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=4114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=4114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}