###前提・実現したいこと
android studio を使ってアプリ内課金を作っています。
アプリ内課金を実装したいです。まずは、課金ダイアログが表示されるようにしたいです。
android studio に実機をつないで、アプリ内課金のテストをしているのですが、課金ダイアログは表示されるかと思いますが、違いますか?
###発生している問題・エラーメッセージ
Webview内の購入ボタンを押した後に、課金ダイアログが表示されません。課金ダイアログが表示されず、落ちる時もあります。どうしたら表示されるかご教授ください。
落ちた際のクラッシュログ 09-30 22:48:37.268 10033-10033/com.bbe.aa A/chromium: [FATAL:jni_android.cc(243)] Please include Java exception stack in crash report 09-30 22:48:37.418 11617-11617/? A/google-breakpad: -----BEGIN BREAKPAD MICRODUMP----- 09-30 22:48:37.418 11617-11617/? A/google-breakpad: V AndroidWebView:59.0.3071.125 09-30 22:48:37.418 11617-11617/? A/google-breakpad: O A arm 04 armv7l KDDI/KYV34_jp_kdi/KYV34:5.1/104.1.2940/104.1.2940:user/release-keys 09-30 22:48:37.418 11617-11617/? A/google-breakpad: P webview 09-30 22:48:37.418 11617-11617/? A/google-breakpad: G OpenGL ES 3.0 V@84.0 AU@05.01.00.042.030 (CL@)|Qualcomm|Adreno (TM) 305 09-30 22:48:37.418 11617-11617/? A/google-breakpad: H 12C00000 FFFF1000 0065 415B7000 A9D7E000 0C:0C 0D:02 0E:02 0F:21 10:06 11:03 12:06 13:04 14:03 15:01 16:03 17:05 18:07 19:09 1A:02 1B:01 1D:01 1E:01 09-30 22:48:37.418 11617-11617/? A/google-breakpad: S 0 BEA369C8 BEA36000 00003000
###該当のソースコード
java
1 IInAppBillingService billingService; 2 3 ServiceConnection mServiceConn = new ServiceConnection() { 4 @Override 5 public void onServiceDisconnected(ComponentName name) { 6 billingService = null; 7 } 8 9 @Override 10 public void onServiceConnected(ComponentName name, IBinder service) { 11 billingService = IInAppBillingService.Stub.asInterface(service); 12 try { 13 int result = billingService.isBillingSupported(3, getPackageName(), "inapp"); 14 if (result != 0) { 15 Toast.makeText(MainActivity.this, "この端末は、課金サービス、未対応です。", Toast.LENGTH_LONG).show(); 16 } 17 } catch (RemoteException e) { 18 e.printStackTrace(); 19 } 20 } 21 }; 22 23 @Override 24 protected void onCreate(Bundle savedInstanceState) { 25 super.onCreate(savedInstanceState); 26 setContentView(R.layout.webview); 27 setTitle(""); 28 // 課金サービス開始 29 Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); 30 serviceIntent.setPackage("com.android.vending"); 31 bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); 32 } 33 } 34 35 private class CustomChrome extends WebChromeClient { 36 // アラートイベントの処理 37 @Override 38 public boolean onJsAlert(WebView view, String url, String message, JsResult result) { 39 if (message.length() != 0) { 40 String params = message; 41 String[] param = params.split("&", 0); 42 String productId = param[0]; 43 String developerPayload = param[1]; 44 try { 45 Bundle buyIntentBundle = billingService.getBuyIntent(3, getPackageName(), productId, "inapp", developerPayload); 46 PendingIntent buyIntent = buyIntentBundle.getParcelable("BUY_INTENT"); 47 Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); 48 serviceIntent.setPackage("com.android.vending"); 49 MainActivity.this.startIntentSenderForResult(buyIntent.getIntentSender(), requestCode, serviceIntent, Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); 50 } catch (Exception e) { 51 e.printStackTrace(); 52 } 53 } 54 result.confirm(); 55 return true; 56 } 57 }
アンドロイドマニフェストには、 <uses-permission android:name="com.android.vending.BILLING"/> を記載しています。
IInAppBillingService.aidl ファイルは、下記に置いています。 \app\src\main\aidl\com\android\vending\billing
###試したこと
sdk23だと購入ボタンが入ったGooglePlayのアラートダイアログが表示されました。
###補足情報(言語/FW/ツール等のバージョンなど)
android studio2.2
sdk25
回答1件
あなたの回答
tips
プレビュー