InApp购买结算:handleActivityResult错误

时间:2019-02-19 06:22:27

标签: java android in-app-purchase

我正在尝试使用名为/identity/manage?ui-culture=fr的库在我的一个Android应用程序中进行inapp订阅

anjlab/android-inapp-billing-v3

bp=new BillingProcessor(InAppPurchaseActivity.this,Globals.APP_LICENSE_KEY,this);
        bp.initialize();
        btnPay=findViewById(R.id.btn_pay);
        btnPay.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            bp.purchase(InAppPurchaseActivity.this,"mypackage_name");
             Log.e("purchase called",Globals.currentUser.type);
         }
        });

我在购买中获得成功,但是我的public void addMonths(Date date, int numMonths){ date.setMonth((date.getMonth() - 1 + numMonths) % 12 + 1); } @Override public void onProductPurchased(@NonNull String productId, TransactionDetails details) { Log.e("onProductPurchased",Globals.currentUser.type); try { DateFormat dateFormat = new SimpleDateFormat(Globals.DATE_FORMAT); Date newDate = new Date(); //dateFormat.parse(u.expiry_date); addMonths(newDate, 1); Globals.currentUser.UpdateType(Globals.TYPE_PREMIUM); Globals.currentUser.UpdateExpiryDate(dateFormat.format(newDate)); android.app.AlertDialog.Builder builder; builder = new android.app.AlertDialog.Builder(InAppPurchaseActivity.this); builder.setMessage("Congrats ! Your have purchased 1 Month Premium Subscription ! Please logout and login again to enjoy premium features"); builder.setNeutralButton("Ok",null); builder.show(); Globals.ShowSnackBar("Item Purchased", btnPay); } catch (Exception ex) { Toast.makeText(InAppPurchaseActivity.this,ex.getMessage(),Toast.LENGTH_LONG).show(); } Log.e("premium",Globals.currentUser.type); } @Override public void onPurchaseHistoryRestored() { } @Override public void onBillingError(int errorCode, @Nullable Throwable error) { } @Override public void onBillingInitialized() { } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (!bp.handleActivityResult(requestCode, resultCode, data)) super.onActivityResult(requestCode, resultCode, data); } @Override public void onDestroy() { if (bp != null) bp.release(); super.onDestroy(); } 从未被致电,而且我遇到了错误onProductPurchased

onActivityResult

相同的代码在我的另一个应用程序中可以正常工作,但是我没有得到这样做的原因。让我知道是否有人可以帮助我解决我的问题。我从最近3个小时开始尝试,结果只是头痛。

谢谢

0 个答案:

没有答案