gpt4 book ai didi

android - BillingService 泄露了 ServiceConnection

转载 作者:太空狗 更新时间:2023-10-29 16:06:29 26 4
gpt4 key购买 nike

我尝试将代码集成到 Blundell's in-app purchasing example 中进入我自己的应用程序,它几乎可以正常工作。我做了一个名为 shop.java 的 Activity ,它有一组按钮,每个按钮对应可以在我的应用程序中购买的每个可能的项目。如果我单击其中一个按钮,则会进行测试购买(“android.test.purchased”)并且似乎已成功执行。日志输出看起来令人放心:

CONFIRM_NOTIFICATIONS Sync Response code: RESULT_OK
Transaction complete
Transaction status: PURCHASED
Item purchased is: android.test.purchased
Received action: com.android.vending.billing.RESPONSE_CODE
checkResponseCode got requestId: 4731640731226687265
checkResponseCode got responseCode: RESULT_OK
Received action: com.android.vending.billing.RESPONSE_CODE
checkResponseCode got requestId: 1172244708705759861
checkResponseCode got responseCode: RESULT_OK
Received action: com.android.vending.billing.RESPONSE_CODE
checkResponseCode got requestId: 2684438012578976155
checkResponseCode got responseCode: RESULT_SERVICE_UNAVAILABLE
Key action: 4
clipservice: android.sec.clipboard.ClipboardExManager@41d443c0
Stopping Service

控制返回到 shop.java。我现在按下后退按钮返回到我的应用程序的主要 Activity 。我假设调用了 shop.java 的 onDestroy 方法,但现在我收到以下错误:

Service com.mycompany.mygame.BillingService has leaked ServiceConnection com.mycompany.mygame.BillingService@41d25498 that was originally bound here

有什么想法吗?

编辑:刚刚注意到,即使我没有尝试购买任何东西,我也会遇到完全相同的错误!

最佳答案

初始化计费服务时,尽量给它应用上下文而不是 Activity 上下文。使用:

getApplicationContext()

关于android - BillingService 泄露了 ServiceConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13125484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com