简体   繁体   中英

Android - how to check if in app purchase has already been done?

How do i check if a in app purchase has been done before? So that my user doesnt need to repurchase the in app purchase upon uninstalling and reinstalling the app?

I have set my in app item to managable in the android market publish page.

i have read about RESTORE_TRANSACTION but I do not know what i need to look for inside this response and also how to test this.

Any help would be greatly appreaciated.

You need to restore the transactions, using the RESTORE_TRANSACTION flag you specified above. You should only do this once, when the application starts for the first time or if the user clears the data.

I would advice to make this process simpler for yourself, you looking into the AndroidBillingLibrary , which allows you to interface with the Android In App Billing in a much simpler manner.

Here is a snippet of how the transactions are restored:

private void restoreTransactions() {
    if (!mBillingObserver.isTransactionsRestored()) {
        BillingController.restoreTransactions(this);
        Toast.makeText(this, R.string.restoring_transactions, Toast.LENGTH_LONG).show();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM