gpt4 book ai didi

java - 在应用程序购买中工作,但方法未执行?

转载 作者:太空宇宙 更新时间:2023-11-04 12:46:14 26 4
gpt4 key购买 nike

我已成功将应用内购买添加到我的应用中,并且一切顺利:

enter image description here

但是if (purchase.getSku().equals("android.test.purchased"))没有通过,所以我无法使用高级版本更新我的 UI!

    public void buy(View v) {

mHelper.launchPurchaseFlow(this, "android.test.purchased", 10001,
mPurchaseFinishedListener, "developerPayLoadString");

}

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {

Toast.makeText(MainActivity.this, "Unable to make purchase.", Toast.LENGTH_SHORT).show();
return;
} else if (purchase.getSku().equals("android.test.purchased")) {
Toast.makeText(MainActivity.this, "Successfully bought product!", Toast.LENGTH_SHORT).show();
}
};

为什么不是 if (purchase.getSku().equals("android.test.purchased"))支付成功了还继续走吗?

谢谢

鲁奇

最佳答案

Security.java中,方法verifyPurchase(),添加以下内容:

 if (BuildConfig.DEBUG) {
Log.v("myActivity", "Debug :)");
return true;
}

所以,整个方法应该如下所示:

  public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {

if (BuildConfig.DEBUG) {
Log.v("myActivity", "Debug :)");
return true;
}

if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
TextUtils.isEmpty(signature)) {
Log.e(TAG, "Purchase verification failed: missing data.");
return false;
}



PublicKey key = Security.generatePublicKey(base64PublicKey);
return Security.verify(key, signedData, signature);
}

关于java - 在应用程序购买中工作,但方法未执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36298320/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com