onepf / OpenIAB

Open In-App Billing for Google Play, SlideMe, Amazon Store, Nokia Store, Samsung Apps, Yandex.Store, Appland, Aptoide, AppMall and Fortumo.
http://onepf.org/openiab/
Apache License 2.0
473 stars 172 forks source link

The callback onIabPurchaseFinished() sometimes is not called #511

Closed Iucone closed 8 years ago

Iucone commented 8 years ago

I am testing IAP with my other account (not the developer one). Usually i press the 'buy' button in my user interface (a DialogFragment), this will call launchPurchaseEvent() method. The google UI for IAP does appears, i cancel it and expect that the callback onIabPurchaseFinished() will be called with an error as result. Everything seems to work fine most of time, but sometimes the onIabPurchaseFinished() callback is not called. Looking at the log cat i can see that, when onIabPurchaseFinished() is not called, the onActivityResult() of my activity is not called too (only onResume()). I have noted also a strange message from android ActivityManager that seems to not appear when everything is working:

W/ActivityManager( 310): startActivity called from non-Activity context: forcing Intent.FLAG_ACTIVITY_NEW_TAK for: Intent { cmp=com.android.vending/com.google.android.finsky.billing.lightpurchase.IabV3Activity (has extras) }

I do not understand why this messages popup, since the context have to be an activity context!!

My application has two activities: a splash-screen activity and the main app activity. The last one (the core of the app and the activity that handle everything) has launchMode=singleTask set in the manifest. I still don't know if this problem is related to the fact that sometimes i test the app in off-line mode (or switch between off line and online), andd i have still to test what happens if the purchase is finalized.

Iucone commented 8 years ago

I want to add that i am testing my app on my LG device (android 4.0.3). I am testing it by manually installing it with adb, because publishing every release in beta everytime take too many hours.

Iucone commented 8 years ago

Ok, i have solved it. There was really a ugly bug in my code, so OpenIAB was using a context in a singleton class (that is, the context sometimes was that of a closed instance of the activity!). Shame on me!