简体   繁体   中英

Android In-App purchase issue

I'm experiencing a weird problem after we've submitted our first app on the Android Market. The app has a in-app purchasing feature which have been fully tested before the release (or at least I thought so).

I'm aware that similar questions might already exists, but I haven't found them and it's quite difficult to describe my problem with only a few words.

The problem appears when a user:

a) downloads our app from Android Market
b) opens the app after download through the OPEN link in Android Market
c) starts a purchase which takes the user back to Android Market.
d) either cancels or completes the purchase

Then:

Instead of returning to our app, the user returns to Android Market (which displays an description of our app with a button to open the app etc). In the LogCat an Response Code is sent from Android Market to the Purchase Observer, but our app (now being in the background) doesn't receive the code and therefor stalls, forever waiting for a response from Android Market. So it's actually two problems, because it's not intentional that the user should return to the Android Market screen after purchasing - our app should be before Market in the history.

Everything works correctly if the user opens our app outside Android Market (eg the Home screen). The observer receives either the cancel or complete Response Code.

We've used Google's own In-App Billing example as our foundation.

I hope this is somewhat understandable.

Thanks in advance

All right, I finally found the answer myself.

I'll try to explain the solution without using any code :)

The PurchaseObserver instance is only available when my activity is active - but it's not active, in the example described above. I made the mistake to think that the PurchaseObserver is where the order should be saved in the database - only to find out that you cannot be certain that the PurchaseObserver exists when a purchase is made. Instead, I now only use the Observer to change the UI and then handle the order information and the database through the ResponseHandler, which always gets called when an purchase has been made in Android Market.

I still think it's odd the user gets thrown back to Android Market instead of our app when an purchase is made (only when the user starts the app through Android Market), but I cannot seem to find an solution or explanation for this.

This is btw impossible to test or reproduce the problem, without having the app on Android Market - so I hope this explanation can help you guys not make the same mistake I've made ;)

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