应用内结算不适用于G1

时间:2011-04-07 06:07:07

标签: android in-app-purchase

我在我的Android应用程序中实现了应用内结算。它在Android版本2.2和市场版本2.3.4的自有设备上运行良好。但是它没有用于测试设备T-Mobile G1与Android 1.6和市场版本1002211(奇怪版本..但它具有应用程序内的计费权限)。抛出异常:

ERROR/Bundle(2079): readBundle: bad magic number
ERROR/Bundle(2079): readBundle: trace = java.lang.RuntimeException
        at android.os.Bundle.readFromParcelInner(Bundle.java:1473)
        at android.os.Bundle.<init>(Bundle.java:82)
        at android.os.Parcel.readBundle(Parcel.java:1344)
        at android.os.Parcel.readBundle(Parcel.java:1329)
        at android.os.Bundle$1.createFromParcel(Bundle.java:1410)
        at android.os.Bundle$1.createFromParcel(Bundle.java:1413)
        at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:102)
        at MyAppPackages.BillingService$RestoreTransactions.run(BillingService.java:310)
        at MyAppPackages.BillingService$BillingRequest.runIfConnected(BillingService.java:118)
        at MyAppPackages.BillingService$BillingRequest.runRequest(BillingService.java:97)
        at MyAppPackages.BillingService.restoreTransactions(BillingService.java:428)
        at MyAppPackages.BillingActivity.restoreDatabase(BillingActivity.java:193)
        at MyAppPackages.BillingActivity.access$000(BillingActivity.java:45)
        at MyAppPackages.BillingActivity$PurchaseObserver.onBillingSupported(BillingActivity.java:107)
        at MyAppPackages.ResponseHandler.checkBillingSupportedResponse(ResponseHandler.java:83)
        at MyAppPackages.BillingService$CheckBillingSupported.run(BillingService.java:188)
        at MyAppPackages.BillingService$BillingRequest.runIfConnected(BillingService.java:118)
        at MyAppPackages.BillingService.runPendingRequests(BillingService.java:521)
        at MyAppPackages.BillingService.onServiceConnected(BillingService.java:554)
        at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1053)
        at android.app.ActivityThread$PackageInfo$ServiceDispatcher$RunConnection.run(ActivityThread.java:1070)
        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4203)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
        at dalvik.system.NativeStart.main(Native Method)

请帮助我了解发生了什么。

1 个答案:

答案 0 :(得分:4)

我在LG P500上遇到过同样的问题,市场已经过时了... 问题是Billing-Service的CheckBillingSupported子类的run()方法。

尽管市场不支持账单,但它将返回“真实”......

响应代码将产生0,因为实际上没有设置额外字段BILLING_RESPONSE_RESPONSE_CODE - 而是默认返回0;顺便提一下,RESULT_OK也是0。

int responseCode = response.getInt(Consts.BILLING_RESPONSE_RESPONSE_CODE);

要解决此问题,请使用以下命令替换呼叫:

int responseCode = response.getInt(Consts.BILLING_RESPONSE_RESPONSE_CODE, -123);

这解决了我的问题。