【发布时间】:2017-01-04 15:28:10
【问题描述】:
我有一个带有订阅的 Android 应用,我使用 IabHelper 来查询用户是否有活动订阅。现在我还需要知道此订阅是否自动续订。
我这样查询订阅状态:
private boolean userIsSubscribed() {
ArrayList<String> skuList = new ArrayList<>();
skuList.add(PREMIUM_SUBSCRIPTION);
// Check the subscription status
try {
Inventory inventory = iabHelper.queryInventory(true, null, skuList);
Purchase purchase = inventory.getPurchase(PREMIUM_SUBSCRIPTION);
// Is the user subscribed?
if (purchase != null && purchase.getPurchaseState() == 0) {
// User is subscribed
Log.d(TAG, "Subscribed.");
// TODO check if subscription is auto-renewing
return true;
} else {
// User is not subscribed
Log.d(TAG, "Not subscribed.");
return false;
}
} catch (IabException | NullPointerException e) {
// There was an error with the subscription process
Log.e(TAG, e.getMessage(), e);
return false;
} catch (IllegalStateException e) {
// IabHelper not set up
Log.e(TAG, e.getMessage(), e);
return false;
}
}
不幸的是,Purchase 对象没有请求自动更新字段的方法。有没有其他方法可以获得这些信息?
【问题讨论】:
标签: android in-app-billing android-billing