在我的应用程序中,我在地牢示例项目中完成了以下代码,以检查该项目是否已购买并更改列表项的文本:
@Override
public void onPurchaseStateChange(PurchaseState purchaseState,
String itemId, int quantity, long purchaseTime,
String developerPayload) {
if (Consts.DEBUG) {
Log.i("Tag", "onPurchaseStateChange() itemId: " + itemId + " "
+ purchaseState);
}
if (purchaseState == PurchaseState.PURCHASED) {
ownedItems.add(itemId);
list.get(purchaseposition).setPurchase("Play");
adapter.notifyDataSetChanged();
}
// YOU can also add other checks here
}
但是当我重新运行应用程序时,它不记得我已经购买了该商品,并提示我再次购买。我怎样才能做到这一点?它对我来说看起来有点复杂。