问题
Ahh the in-app billing problems never end! ^.^ I have everything working properly to show the transaction page for the in-app purchase. If I complete the purchase it returns me to my application and after about 10 seconds it verifies the purchase and I receive the item.
On the other hand, if I press the back button after returning to the application and switch to another activity it never processes the transaction. Even if I return to the in-app billing activity I never receive my purchased item, like the purchase has been completely forgotten about if you call finish().
What can I do so that it either completes the transaction and gives the item when I return to the in-app billing activity or processes the transaction and gives the purchased item anywhere that I am at within my application?
回答1:
Receiving the notification is handled by a broadcast receiver which is independent from your activities. How you handle the notification is up to you. In the default implementation you have a PurchaseObserver
interface implemented by an Activity. You can have multiple activities implement it and register to be called accordingly. Or, you can have related code in a base activity, so that all your activities are PurchaseObserver
's (might not be practical if you have a lot of activities).
来源:https://stackoverflow.com/questions/11076038/in-app-billing-switching-activities