嗨,我已经使用android-inapp-billing-v3为一个项目实施了一年订阅的 inapp billing V3 。我想在我的应用程序中显示剩余天数。我打电话getSubscriptionTransactionDetails
来获取产品的交易详细信息,但它总是返回null
。这是我的代码。
private BillingProcessor startInappCheck(){
bp = new BillingProcessor(mContext, BASE64ENCODEDPUBLICKEY, new BillingProcessor.IBillingHandler() {
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
LogUtils.e(TAG, "onProductPurchased :" +productId);
// showToast("onProductPurchased: " + productId);
}
@Override
public void onBillingError(int errorCode, Throwable error) {
LogUtils.e(TAG, "onBillingError :" +errorCode);
}
@Override
public void onBillingInitialized() {
// showToast("onBillingInitialized");
readyToPurchase = true;
try{
SkuDetails subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID);
LogUtils.d(TAG, "Owned Subscription: " + subs.toString());
TransactionDetails tr = bp.getSubscriptionTransactionDetails(SUBSCRIPTION_ID);
LogUtils.d(TAG, "Owned Subscription: " + tr.toString());
}catch (Exception e) {
// TODO: handle exception
}
}
@Override
public void onPurchaseHistoryRestored() {
// showToast("onPurchaseHistoryRestored");
for(String sku : bp.listOwnedSubscriptions()){
LogUtils.d(TAG, "Owned Subscription: " + sku);
}
// showToast("onPurchaseHistoryRestored");
}
});
return bp;
}
我从onCreate
.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if (!bp.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
}
我的订阅项目按钮在fragment
. 还有一个问题,我发现成功订阅后 onProductPurchased
没有被调用,但我已经实现了onResume
更新 UI 如果bp.isSubscribed(SUBSCRIPTION_ID)
返回的逻辑true
。请告诉我如何获取订阅开始日期和到期日期。