问题描述
我在遇到麻烦搞清楚应用内结算过程中应该如何进行广播事件的工作,当应用程序没有运行。我有一个管理产品设置,就我所看到的,运作良好。随着测试帐户,我能够购买我发布的组件和我的测试应用程序进行处理,保持其状态。然后,我通过我的商家账户取消订单并申请重新接收事件,并删除该项目。
I'm having trouble figuring out how the in-app billing process is supposed to work for broadcast events when the application isn't running. I have a managed product setup and as far as I can see, is working well. With a test account I'm able to purchase my published component and my test application handles it, retaining its state. I then cancel this order via my merchant account and the application again receives the event and removes the item.
将出现问题的时候,而不是取消订单,而应用程序是活跃。我退出了它(不带回家,与多个后退按钮)。如果我现在取消的项目,我的'的设备的'得到通知的购买失败,但是当我开始我的应用程序好像没有什么改变,因此该项目的状态仍然购买。
The problem occurs when instead of cancelling the order while the application is active. I exit out of it (not with home, with multiple back buttons). If I cancel the item now, my 'device' gets a notification 'purchase failed', but when I start my application nothing seems to happen and thus the state of the item is still purchased.
我不知道,如果计费服务仍在运行与否。鉴于文档说我的应用程序必须发回一个CONFIRM_NOTIFICATIONS或它不断发送它,我只能假设它是。但是为什么它不能与我的数据库交互,并像它如果正确的应用程序被激活?删除项目
I'm not sure if billing service is still running or not. Given the documentation says my application must send back a CONFIRM_NOTIFICATIONS or it keeps sending it I can only assume it is. However why is it unable to interact with my database and remove the item like it does correctly if the application is active?
我希望tihs是清楚的,我道歉,如果它之前已经讨论过,我找不到我的搜索任何东西。
I hope tihs is clear, and I apologize if it has been discussed before, I couldn't find anything in my searches.
推荐答案
道歉回答我的问题,但希望我的发现将帮助其他人感到困惑,因为我是。
Apologies for answering my own question but hopefully my findings will help others that were confused as I was.
我的问题就在想,在这个例子中提供的Dungeons.java类有所需的所有修改的code。该示例的设计有其嵌套在观察者类有活性,而在用户和商店进行交互数据库实现。它为我创造的问题,我的问题列出,如果一个交易时,该观测未注册或应用程序没有运行的事实后取消会发生什么。
My issue was thinking that the Dungeons.java class provided in the example had all the code needed for modification. The example design has its database implementation nested in the observer class that is active while the user is interacting with the store. The issue it created for me outlined in my question, what happens if a transaction is cancelled after the fact when this observer isn't registered or the application isn't running.
从试错我的解决办法是采取数据库交互进行观测,并把它放在
From trial and error my solution was to take the database interaction out of the observer and place it in
private void purchaseStateChanged(int startId, String signedData, String signature) {
在BillingService有阶级的。
of the BillingService class.
这篇关于Android的应用内结算付款抵消,应用不积极的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!