简体   繁体   English

Android应用内购买问题

[英]Android In-App purchase issue

I'm experiencing a weird problem after we've submitted our first app on the Android Market. 我们在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 a)从Android Market下载我们的应用程序
b) opens the app after download through the OPEN link in Android Market b)通过Android Market中的OPEN链接下载后打开应用程序
c) starts a purchase which takes the user back to Android Market. c)开始购买,将用户带回Android Market。
d) either cancels or completes the purchase d)取消或完成购买

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). 用户不返回我们的应用程序,而是返回Android Market(显示我们的应用程序的描述,其中包含用于打开应用程序的按钮等)。 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. 在LogCat中,响应代码从Android Market发送到Purchase Observer,但是我们的应用程序(现在在后台)没有收到代码,因此永远等待来自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. 所以这实际上是两个问题,因为用户在购买后应该返回Android Market屏幕并不是故意的 - 我们的应用程序应该在历史市场之前。

Everything works correctly if the user opens our app outside Android Market (eg the Home screen). 如果用户在Android Market之外打开我们的应用程序(例如主屏幕),一切正常。 The observer receives either the cancel or complete Response Code. 观察者收到取消或完整的响应代码。

We've used Google's own In-App Billing example as our foundation. 我们已经使用Google自己的应用内结算示例作为我们的基础。

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. PurchaseObserver实例仅在我的活动处于活动状态时可用 - 但在上述示例中它不活动。 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. 我错误地认为PurchaseObserver是订单应保存在数据库中的地方 - 只是为了发现您在购买时无法确定PurchaseObserver是否存在。 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. 相反,我现在只使用Observer来更改UI,然后通过ResponseHandler处理订单信息和数据库,当在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. 我仍然认为,当进行购买时(仅当用户通过Android Market启动应用程序时)用户被重新投入Android Market而不是我们的应用程序是奇怪的,但我似乎无法找到解决方案或解释。

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 ;) 如果没有Android Market上的应用程序,这是不可能测试或重现问题的 - 所以我希望这个解释可以帮助你们不要犯同样的错误;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM