So erhalten Sie das Ablaufdatum des Abonnements in inapp v3 android
Hi Ich habe inapp billing V3 für ein Jahresabonnement für einen Artikel mit @ implementier android-inapp-billing-v3. Ich möchte die verbleibenden Tage in meiner App anzeigen. Ich rufe angetSubscriptionTransactionDetails
, um Transaktionsdetails für das Produkt abzurufen, aber es gibt immer @ zurünull
. Hier ist mein Code.
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;
}
Ich habe diese Methode von @ aufgerufonCreate
.
@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);
}
Meine Abonnementelement-Schaltfläche in einem @ implementiefragment
. Ein weiteres Problem fand ich, dass nach erfolgreicher Anmeldung dasonProductPurchased
wird nicht aufgerufen, aber ich habe die Logik in @ implementieonResume
, um die Benutzeroberfläche zu aktualisieren, wennbp.isSubscribed(SUBSCRIPTION_ID)
kehrt zurücktrue
. Bitte teilen Sie mir mit, wie ich das Startdatum und das Ablaufdatum des Abonnements erhalten kann.