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

泪湿孤枕 提交于 2019-12-11 13:18:24

问题


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.


回答1:


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();
    }
}


来源:https://stackoverflow.com/questions/9819116/android-how-to-check-if-in-app-purchase-has-already-been-done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!