我已经在我的应用程序中实现了应用程序内购买,但它们只能在我的 onPurchaseFinished 代码中购买一次,我应该在哪里调用 onConsumeListener?
@Override
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) {
if (responseCode == BillingClient.BillingResponse.OK
&& purchases != null) {
Toast.makeText(getContext(), "Purchased", Toast.LENGTH_SHORT).show();
adddata();
for (Purchase purchase : purchases) {
}
} else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
// Handle an error caused by a user cancelling the purchase flow.
} else if (responseCode == BillingClient.BillingResponse.ITEM_ALREADY_OWNED) {
Toast.makeText(getContext(), "Purchase Limit Reached! Try again later", Toast.LENGTH_SHORT).show();
} else{
// Handle any other error codes.
}
}
Run Code Online (Sandbox Code Playgroud)