{"id":1834,"date":"2026-11-20T16:00:59","date_gmt":"2026-11-20T07:00:59","guid":{"rendered":"https:\/\/plusload.net\/?p=1834"},"modified":"2026-11-20T16:36:58","modified_gmt":"2026-11-20T07:36:58","slug":"androidstudio%e3%81%a7webview%e3%82%92%e6%93%8d%e4%bd%9c%e3%81%99%e3%82%8b%ef%bc%88%e4%ba%8c%e8%bc%aa%e8%bb%8a%e7%82%b9%e6%a4%9c%e6%95%b4%e5%82%99db%e3%82%a2%e3%83%97%e3%83%aa%e3%81%ae%e5%a0%b4","status":"publish","type":"post","link":"https:\/\/plusload.net\/?p=1834","title":{"rendered":"AndroidStudio\uff1akotlin\u3067WebView\u3092\u64cd\u4f5c\u3059\u308b\uff08\u4e8c\u8f2a\u8eca\u70b9\u691c\u6574\u5099DB\u30a2\u30d7\u30ea\u306e\u5834\u5408\uff09"},"content":{"rendered":"<pre>\/\/ GooglePlay\u3067\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\r\npackage net.plusload.biketenken\r\n\/\/ \u8aad\u307f\u8fbc\u3080\u30e2\u30b8\u30e5\u30fc\u30eb\r\nimport android.annotation.SuppressLint\r\nimport android.os.Bundle\r\nimport android.webkit.JavascriptInterface\r\nimport android.webkit.WebView\r\nimport android.webkit.WebViewClient\r\nimport androidx.appcompat.app.AppCompatActivity\r\nimport com.android.billingclient.api.AcknowledgePurchaseParams\r\nimport com.android.billingclient.api.BillingClient\r\nimport com.android.billingclient.api.BillingClientStateListener\r\nimport com.android.billingclient.api.BillingFlowParams\r\nimport com.android.billingclient.api.BillingResult\r\nimport com.android.billingclient.api.PendingPurchasesParams\r\nimport com.android.billingclient.api.Purchase\r\nimport com.android.billingclient.api.PurchasesUpdatedListener\r\nimport com.android.billingclient.api.QueryProductDetailsParams\r\nimport java.io.OutputStreamWriter\r\nimport java.net.HttpURLConnection\r\nimport java.net.URL\r\n\r\n\/\/ \u672c\u4f53\r\nclass MainActivity : AppCompatActivity() {\r\n  \/\/ WebView\u306e\u521d\u671f\u5316\r\n  private lateinit var webView: WebView\r\n  \/\/ GooglePlayAPP\u5185\u8ab2\u91d1\u6a5f\u80fd\u306e\u521d\u671f\u5316\r\n  private lateinit var billingClient: BillingClient\r\n\r\n  \/\/ currentProductId,currentChassesN\u306e\u521d\u671f\u5316\r\n  private var currentProductId = \"\"\r\n  private var currentChassesN = \"\"\r\n\r\n  \/\/ WebView\u3067Javascript\u306e\u8b66\u544a\u3092\u975e\u8868\u793a\r\n  @SuppressLint(\"SetJavaScriptEnabled\")\r\n  override fun onCreate(savedInstanceState: Bundle?) {\r\n\r\n    setTheme(R.style.Theme_TenkenApp)\r\n\r\n    super.onCreate(savedInstanceState)\r\n\r\n    setContentView(R.layout.activity_main)\r\n\r\n    webView = findViewById(R.id.webview)\r\n\r\n    val sets = webView.settings\r\n\r\n    sets.javaScriptEnabled = true\r\n    sets.domStorageEnabled = true\r\n\r\n    webView.webViewClient = WebViewClient()\r\n\r\n    webView.addJavascriptInterface(\r\n      PurchaseBridge(),\r\n      \"Android\"\r\n    )\r\n\r\n    billingClient =\r\n      BillingClient.newBuilder(this)\r\n      .enablePendingPurchases(\r\n        PendingPurchasesParams\r\n        .newBuilder()\r\n        .enableOneTimeProducts()\r\n        .build()\r\n      )\r\n      .setListener(purchaseListener)\r\n      .build()\r\n\r\n    billingClient.startConnection(\r\n      object : BillingClientStateListener {\r\n\r\n        override fun onBillingSetupFinished(\r\n          billingResult: BillingResult\r\n        ) {\r\n        }\r\n\r\n        override fun onBillingServiceDisconnected() {\r\n        }\r\n      }\r\n    )\r\n \r\n    \/\/ \u63a5\u7d9a\u3059\u308b\u969b\u306bPOST\u3059\u308b\u6697\u53f7\u3092\u8a2d\u5b9a\r\n    val postData =\r\n      \"tenken_id=**************\"\r\n      .toByteArray(Charsets.UTF_8)\r\n    \/\/ \u63a5\u7d9a\u5148\r\n    webView.postUrl(\r\n      \"https:\/\/plusload.net\/tenken\/tenken_login.php\",\r\n      postData\r\n    )\r\n}\r\n<\/pre>\n<p>\u4ee5\u4e0aAPP\u5185\u8ab2\u91d1\u306e\u521d\u671f\u5316\u3068\u6700\u521d\u306e\u30da\u30fc\u30b8\u307e\u3067\u306ePOST\u64cd\u4f5c\u306e\u624b\u9806<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ GooglePlay\u3067\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u540d package net.plusload.biketenken \/\/ \u8aad\u307f\u8fbc\u3080\u30e2\u30b8\u30e5\u30fc\u30eb import android.annotation.SuppressLint impo&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,10,5,6],"tags":[],"class_list":["post-1834","post","type-post","status-publish","format-standard","hentry","category-android","category-javascript","category-php","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/posts\/1834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plusload.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1834"}],"version-history":[{"count":2,"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/posts\/1834\/revisions"}],"predecessor-version":[{"id":1836,"href":"https:\/\/plusload.net\/index.php?rest_route=\/wp\/v2\/posts\/1834\/revisions\/1836"}],"wp:attachment":[{"href":"https:\/\/plusload.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plusload.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plusload.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}