Android 应用程序中的计费未在我的班级中触发事件

发布于 2024-11-28 05:31:11 字数 1297 浏览 0 评论 0原文

我使用“Dungeon”示例作为我的代码的基础,因此它是目前的标准示例代码。

我可以致电市场并成功下订单。在 BillingReciever 事件中 正如我所期望的那样, public void onReceive 被调用两次,我可以在那里放置一个断点并查看结果,这很好。

checkResponseCode 也被调用并启动

    Intent intent = new Intent(Consts.ACTION_RESPONSE_CODE);
    intent.setClass(context, BillingService.class);
    intent.putExtra(Consts.INAPP_REQUEST_ID, requestId);
    intent.putExtra(Consts.INAPP_RESPONSE_CODE, responseCodeIndex);
    context.startService(intent);

,执行停止,我的应用程序返回到运行状态。

我有一个扩展的PurchaseObserver 类,它应该响应账单更改,我尝试以两种不同的方式启动它

mPurchaseObserver = new iPurchaseObserver(this,mHandler);

private class iPurchaseObserver extends PurchaseObserver {
            public iPurchaseObserver(UpgradeActivity upgradeActivity, Handler handler) {
                super(upgradeActivity, handler);
            }

,并且

mPurchaseObserver = new iPurchaseObserver(mHandler);

private class iPurchaseObserver extends PurchaseObserver {
            public iPurchaseObserver( Handler handler) {
                super(upgradeActivity.this, handler);
            }

PurchaseObserver 中的任何事件/方法都不会被触发,即onPurchaseStateChange。

我怀疑它是我在构建 PurchasingObserver 时传递或使用的 Activity Context,但我不确定,并且将不胜感激!

谢谢

I am using the 'Dungeon' example as a basis for my code, so it is the standard examplecode for now.

I can call the Market place and successfully place an order. Within BillingReciever the event
public void onReceive is called twice, as I would expect and I can put a breakpoint there and see the result which is fine.

checkResponseCode gets called too and starts

    Intent intent = new Intent(Consts.ACTION_RESPONSE_CODE);
    intent.setClass(context, BillingService.class);
    intent.putExtra(Consts.INAPP_REQUEST_ID, requestId);
    intent.putExtra(Consts.INAPP_RESPONSE_CODE, responseCodeIndex);
    context.startService(intent);

And there the execution stops, and my app returns to a run state.

I have an extended PurchaseObserver class which is supposed to respond to billing changes, which I have tried starting two different ways

mPurchaseObserver = new iPurchaseObserver(this,mHandler);

private class iPurchaseObserver extends PurchaseObserver {
            public iPurchaseObserver(UpgradeActivity upgradeActivity, Handler handler) {
                super(upgradeActivity, handler);
            }

And

mPurchaseObserver = new iPurchaseObserver(mHandler);

private class iPurchaseObserver extends PurchaseObserver {
            public iPurchaseObserver( Handler handler) {
                super(upgradeActivity.this, handler);
            }

None of the events/methods within the PurchaseObserver are fired, i.e onPurchaseStateChange.

I am suspecting it is the Activity Context I am passing or using when constructing my PurchaseObserver, but I am not sure, and advise would be appreciated!

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情洁癖 2024-12-05 05:31:11

在浪费了很多时间之后终于找到了它。我将这些类放在一个文件夹中,当我将它们移回根目录时,它们就起作用了。

Found it, after loads and loads of wasted time. I had put the classes in a folder, when I moved them back to the root, they worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文