How can I verify user has already done in purchase In my Android App without open Purchase Dialog?

强颜欢笑 提交于 2019-12-23 03:04:54

问题


I have one application in that i have put In App Purchase when User open Application i check first time In Purchase happen or not using launchPurchaseFlow(using automatic call) because of this open Dialog of In App purchase(i am call this methode first time because suppose user have done in app purchase he is reinstalling App so check in Purchase happen or not this methode give response Already Purchase so i can know not to display add ) so how can i call this methode and ignore the in purchase dialog first time ? what change i do in launchPurchaseFlow methode of IabHelper.java Thanks in Advance....


回答1:


You should query for purchased items instead of launchPurchaseFlow.

To retrieve information about purchases made by a user from your app, call the getPurchases method on the In-app Billing Version 3 service. Pass in to the method the In-app Billing API version (“3”), the package name of your calling app, and the purchase type (“inapp” or "subs").

Bundle ownedItems = mService.getPurchases(3, getPackageName(),
"inapp", null); 

The Google Play service returns only the purchases made by the user account that is currently logged in to the device.

To query for active subscriptions, use the getPurchases method, again with the product type parameter set to "subs".

Bundle activeSubs = mService.getPurchases(3, "com.example.myapp",
                   "subs", continueToken);


来源:https://stackoverflow.com/questions/34505416/how-can-i-verify-user-has-already-done-in-purchase-in-my-android-app-without-ope

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