{"id":542,"date":"2022-11-30T10:29:19","date_gmt":"2022-11-30T01:29:19","guid":{"rendered":"https:\/\/www.dogrow.net\/android\/?p=542"},"modified":"2023-01-12T14:16:07","modified_gmt":"2023-01-12T05:16:07","slug":"29-androidemulator%e3%81%8b%e3%82%89http%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/android\/29-androidemulator%e3%81%8b%e3%82%89http%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%80%82\/","title":{"rendered":"(29) AndroidEmulator\u304b\u3089HTTP\u63a5\u7d9a\u3059\u308b\u3002"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u3084\u308a\u305f\u3044\u3053\u3068\u304c\u4e09\u3064\u3042\u308b\u3002<\/p>\n<p>\u30101\u756a\u76ee\u3011AndroidEmulator\u4e0a\u3067\u52d5\u4f5c\u3059\u308b\u30a2\u30d7\u30ea\u304b\u3089\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTPS\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u3002<br \/>\n\u30102\u756a\u76ee\u3011AndroidEmulator\u4e0a\u3067\u52d5\u4f5c\u3059\u308b\u30a2\u30d7\u30ea\u304b\u3089\u3001LAN\u4e0a\uff06\u4ed6\u30de\u30b7\u30f3\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTP\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u3002<br \/>\n\u30103\u756a\u76ee\u3011AndroidEmulator\u4e0a\u3067\u52d5\u4f5c\u3059\u308b\u30a2\u30d7\u30ea\u304b\u3089\u3001\u540c\u4e00\u30de\u30b7\u30f3\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTP\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u3002<\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u305f<\/h1>\n<p>\u30101\u756a\u76ee\u3011\uff5e\u30103\u756a\u76ee\u3011\u3067\u76f8\u9055\u70b9\u306f\u50c5\u304b\u3001\u6c17\u306b\u3059\u308b\u307b\u3069\u306e\u9055\u3044\u306f\u306a\u304b\u3063\u305f\u3002<\/p>\n<h2 class=\"my_h\">\u30101\u756a\u76ee\u3011\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTPS\u30a2\u30af\u30bb\u30b9<\/h2>\n<h3 class=\"my_h\">(1) INTERNET\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3059\u308b\u3002<\/h3>\n<p><span class=\"my_fc_blueB\">AndroidManufest.xml<\/span> \u306b 4\u884c\u76ee\u3092\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [4]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\r\n    xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;&gt;\r\n    &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; \/&gt;\r\n    &lt;application\r\n        android:allowBackup=&quot;true&quot;\r\n        android:dataExtractionRules=&quot;@xml\/data_extraction_rules&quot;\r\n        android:fullBackupContent=&quot;@xml\/backup_rules&quot;\r\n<\/pre>\n<h3 class=\"my_h\">(2) HTTPS\u63a5\u7d9a\u3092\u5f37\u5236\u3059\u308b\u3002\uff08\u5fc5\u8981\u306a\u5834\u5408\uff09<\/h3>\n<p>\u65b0\u898f\u306b XML\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3002\u540d\u524d\u306f\u4f55\u3067\u3082\u3088\u3044\u3002<br \/>\n\u3053\u3053\u3067\u306f <span class=\"my_fc_blueB\">communication_rules.xml<\/span> \u3068\u3057\u3066\u4f5c\u6210\u3057\u3001<span class=\"my_fc_blueB\">\/res\/xml<\/span> \u30d5\u30a9\u30eb\u30c0\u306b\u914d\u7f6e\u3057\u305f\u3002<\/p>\n<p><span class=\"my_fw_bold my_fs_big2\">\u624b\u9806\uff1a<\/span><br \/>\n1. xml\u30d5\u30a9\u30eb\u30c0\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n2. \u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066 popup menu\u3092\u8868\u793a\u3059\u308b\u3002<br \/>\n3. [New]\uff0d[File]\u30e1\u30cb\u30e5\u30fc\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n4. \u30d5\u30a1\u30a4\u30eb\u540d <span class=\"my_fc_blueB\">communication_rules.xml<\/span> \u3092\u5165\u529b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;network-security-config&gt;\r\n    &lt;domain-config usesCleartextTraffic=&quot;false&quot;&gt;\r\n        &lt;domain includeSubdomains=&quot;true&quot;&gt;www.dogrow.net&lt;\/domain&gt;\r\n    &lt;\/domain-config&gt;\r\n&lt;\/network-security-config&gt;\r\n<\/pre>\n<p>\u6b21\u306b\u3001\u4f5c\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u3092 <span class=\"my_fc_blueB\">AndroidManufest.xml<\/span> \u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u30027\u884c\u76ee\u3092\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [7]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;manifest xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\r\n\u00a0\u00a0\u00a0\u00a0xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; \/&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;!-- android:usesCleartextTraffic=&quot;true&quot; --&gt;\r\n\u00a0\u00a0\u00a0\u00a0&lt;application\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0android:networkSecurityConfig=&quot;@xml\/communication_rules&quot;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0android:allowBackup=&quot;true&quot;\r\n :\r\n<\/pre>\n<h3 class=\"my_h\">(3) Gradle\u306b OkHTTP\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8ffd\u52a0<\/h3>\n<p><a href=\"https:\/\/gradle.org\/\" target=\"_blank\" rel=\"noopener\">Gradle<\/a>\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u30d3\u30eb\u30c9\u5b9f\u884c\u3092\u5236\u5fa1\u3059\u308b\u30c4\u30fc\u30eb\u3002<br \/>\n\u4eca\u56de\u306f <a href=\"https:\/\/square.github.io\/okhttp\/\" target=\"_blank\" rel=\"noopener\">OkHttp<\/a>\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u4f7f\u3046\u3002<\/p>\n<p><span class=\"my_fc_blueB\">build.gradle.<\/span><br \/>\n7\u884c\u76ee\u3092\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<pre class=\"brush: bash; highlight: [8]; title: ; notranslate\" title=\"\">\r\ndependencies {\r\n    implementation 'androidx.appcompat:appcompat:1.4.1'\r\n    implementation 'com.google.android.material:material:1.5.0'\r\n    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'\r\n    testImplementation 'junit:junit:4.13.2'\r\n    androidTestImplementation 'androidx.test.ext:junit:1.1.3'\r\n    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'\r\n    implementation 'com.squareup.okhttp3:okhttp:4.10.0'\r\n}\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/android\/wp-content\/uploads\/2022\/11\/i001-4.jpg\" alt=\"\" class=\"my_add_bs1\" \/><\/p>\n<p>\u8a18\u8ff0\u5f8c\u306f\u3001Sync now \u30e1\u30cb\u30e5\u30fc\u3092\u9078\u629e\u3057\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/android\/wp-content\/uploads\/2022\/11\/i002-4.jpg\" alt=\"\" class=\"my_add_bs1\" \/><\/p>\n<h3 class=\"my_h\">(4) \u30d7\u30ed\u30b0\u30e9\u30e0\u4e2d\u3067 HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u767a\u884c<\/h3>\n<p>\u4ee5\u4e0b\u306e\u6a5f\u80fd\u3092\u6301\u3064 Java\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u305f\u3002<br \/>\n1) URL\u3092\u6307\u5b9a\u3057\u3001HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u767a\u884c\u3059\u308b\u3002<br \/>\n2) HTTP\u30ec\u30b9\u30dd\u30f3\u30b9\u304b\u3089\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u304c\u51fa\u529b\u3057\u305f\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u3001\u30c7\u30d0\u30c3\u30b0\u30ed\u30b0\u306b\u8868\u793a\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npublic void sendHttpGet(){\r\n    try{\r\n        sendHttpReq(&quot;http:\/\/www.dogrow.net\/MyAPP&quot;);\r\n    }catch(Exception e){\r\n        Log.e(&quot;MyAPP&quot;, e.getMessage());\r\n    }\r\n}\r\n\r\nprivate void sendHttpReq(String url) throws IOException{\r\n    OkHttpClient c = new OkHttpClient();\r\n    Request req = new Request.Builder().url(url).build();\r\n    c.newCall(req).enqueue(new Callback(){\r\n        @Override\r\n        public void onResponse(@NotNull Call call, @NotNull Response resp) throws IOException{\r\n            Log.d(&quot;MyAPP&quot;, resp.body().string());\r\n        }\r\n        @Override\r\n        public void onFailure(@NotNull Call call, @NotNull IOException e){\r\n            Log.e(&quot;MyAPP&quot;, e.getMessage());\r\n        }\r\n    });\r\n}\r\n<\/pre>\n<h2 class=\"my_h\">\u30102\u756a\u76ee\u3011LAN\u4e0a\uff06\u4ed6\u30de\u30b7\u30f3\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTP\u30a2\u30af\u30bb\u30b9<\/h2>\n<p>\u4e0a\u8a18\u306e\u30101\u756a\u76ee\u3011\u304b\u3089\u306e\u5909\u66f4\u70b9\u306e\u307f\u3092\u8a18\u3059\u3002<\/p>\n<h3 class=\"my_h\">(1) \u901a\u4fe1\u60c5\u5831\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/h3>\n<p><span class=\"my_fc_blueB\">communication_rules.xml<\/span> \u3092\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<p>3\u884c\u76ee: \u975e\u30bb\u30ad\u30e5\u30a2\u306a HTTP \u63a5\u7d9a\u3082\u8a31\u53ef\u3059\u308b\u3002<br \/>\n\u3053\u308c\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001HTTPS\u3067\u306a\u3044\u5834\u5408\u306b\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nCLEARTEXT communication to 192.168.2.39 not permitted by network security policy\r\n<\/pre>\n<p>3\u884c\u76ee: \u5e73\u6587\uff08\u975e\u30bb\u30ad\u30e5\u30a2\u306aHTTP\uff09\u3067\u306e\u901a\u4fe1\u3092\u8a31\u53ef\u3059\u308b\u3002<br \/>\n4\u884c\u76ee: \u63a5\u7d9a\u3092\u8a31\u53ef\u3059\u308bIP\u30a2\u30c9\u30ec\u30b9\u3082\u3057\u304f\u306f\u30db\u30b9\u30c8\u540d\u3092\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [3,4]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;\r\n&lt;network-security-config&gt;\r\n    &lt;domain-config cleartextTrafficPermitted=&quot;true&quot;&gt;\r\n        &lt;domain includeSubdomains=&quot;true&quot;&gt;192.168.2.39&lt;\/domain&gt;\r\n    &lt;\/domain-config&gt;\r\n&lt;\/network-security-config&gt;\r\n<\/pre>\n<h2 class=\"my_h\">\u30103\u756a\u76ee\u3011\u540c\u4e00\u30de\u30b7\u30f3\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTP\u30a2\u30af\u30bb\u30b9<\/h2>\n<p>\u4e0a\u8a18\u306e\u30102\u756a\u76ee\u3011\u304b\u3089\u306e\u5909\u66f4\u70b9\u306e\u307f\u3092\u8a18\u3059\u3002<\/p>\n<h3 class=\"my_h\">(1) \u901a\u4fe1\u60c5\u5831\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/h3>\n<p><span class=\"my_fc_blueB\">communication_rules.xml<\/span> \u3092\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<p>4\u884c\u76ee: \u63a5\u7d9a\u3092\u8a31\u53ef\u3059\u308b\u30db\u30b9\u30c8\u540d\u306b localhost \u3092\u6307\u5b9a\u3059\u308b\u3002(127.0.0.1 or LAN\u4e0a\u306eIP\u30a2\u30c9\u30ec\u30b9\u3067\u3088\u3044)<\/p>\n<pre class=\"brush: xml; highlight: [4]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;\r\n&lt;network-security-config&gt;\r\n    &lt;domain-config cleartextTrafficPermitted=&quot;true&quot;&gt;\r\n        &lt;domain includeSubdomains=&quot;true&quot;&gt;localhost&lt;\/domain&gt;\r\n    &lt;\/domain-config&gt;\r\n&lt;\/network-security-config&gt;\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 \u3084\u308a\u305f\u3044\u3053\u3068\u304c\u4e09\u3064\u3042\u308b\u3002 \u30101\u756a\u76ee\u3011AndroidEmulator\u4e0a\u3067\u52d5\u4f5c\u3059\u308b\u30a2\u30d7\u30ea\u304b\u3089\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e Web\u30b5\u30a4\u30c8\u306b HTTPS\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u3002 \u30102\u756a\u76ee\u3011AndroidEmulator\u4e0a\u3067\u52d5\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/android\/29-androidemulator%e3%81%8b%e3%82%89http%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e3%80%82\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-542","post","type-post","status-publish","format-standard","hentry","category-androidstudio","category-http"],"views":1247,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/comments?post=542"}],"version-history":[{"count":21,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/542\/revisions"}],"predecessor-version":[{"id":591,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/posts\/542\/revisions\/591"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/media?parent=542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/categories?post=542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/android\/wp-json\/wp\/v2\/tags?post=542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}