android恢复事务在退出后不断关闭应用程序

时间:2012-12-24 00:46:02

标签: android transactions restore in-app-billing

我根据地下城样本使用代码。除了一件事,一切都很好。事情是恢复交易。当我以与示例中相同的方式调用恢复事务时,一切似乎都很好。看起来他没有产生任何错误。但后来我等了3到10分钟(我就足以得到eosrom谷歌服务器)。但是没有回应....我点点kof我做了一些方式...... ??

这是我用于恢复转换的代码...

mBillingService.restoreTransactions(); 

public boolean restoreTransactions() {
    return new RestoreTransactions().runRequest();
}
class RestoreTransactions extends BillingRequest {
    long mNonce;

    public RestoreTransactions() {
        // This object is never created as a side effect of starting this
        // service so we pass -1 as the startId to indicate that we should
        // not stop this service after executing this request.
        super(-1);
    }

    @Override
    protected long run() throws RemoteException {
        mNonce = Security.generateNonce();

        Log.d("running", "running restore request");
        Bundle request = makeRequestBundle("RESTORE_TRANSACTIONS");
        request.putLong(Consts.BILLING_REQUEST_NONCE, mNonce);
        Bundle response = mService.sendBillingRequest(request);
        logResponseCode("restoreTransactions", response);
        return response.getLong(Consts.BILLING_RESPONSE_REQUEST_ID,
                Consts.BILLING_RESPONSE_INVALID_REQUEST_ID);
    }

    @Override
    protected void onRemoteException(RemoteException e) {
        super.onRemoteException(e);
        Security.removeNonce(mNonce);
    }

    @Override
    protected void responseCodeReceived(ResponseCode responseCode) {
        ResponseHandler.responseCodeReceived(BillingService.this, this, responseCode);
    }
}   

实际上与地下城样本相同。但我对此片段没有任何回应。但如果我想买一件商品就没问题。 那么有谁知道如何解决这个问题?我正在收到购买的回复,但没有回复....

毕竟如果我完成了我的意图并完成了我的应用程序,则会发生以下错误。似乎响应在应用程序结束后出现。它不是在运行期间,而是在完成所有意图之后。

另一个奇怪的事情是,在销毁时,我正在取消绑定服务和上下文以进行计费。事实上,这甚至应该被称为?我想不是 ?

有谁知道如何解决这个问题? 提前谢谢!

以下日志cat错误。

12-24 01:33:06.212: E/AndroidRuntime(27721): FATAL EXCEPTION: main
        12-24 01:33:06.212: E/AndroidRuntime(27721): java.lang.RuntimeException: Unable to start        service .BillingService@40da8db0 with null: java.lang.NullPointerException
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2749)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.ActivityThread.access$1900(ActivityThread.java:139)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.os.Handler.dispatchMessage(Handler.java:99)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.os.Looper.loop(Looper.java:156)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.ActivityThread.main(ActivityThread.java:4987)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at java.lang.reflect.Method.invokeNative(Native Method)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at java.lang.reflect.Method.invoke(Method.java:511)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at dalvik.system.NativeStart.main(Native Method)
    12-24 01:33:06.212: E/AndroidRuntime(27721): Caused by: java.lang.NullPointerException
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at .BillingService.handleCommand(BillingService.java:431)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at .BillingService.onStart(BillingService.java:421)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.Service.onStartCommand(Service.java:438)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2726)
    12-24 01:33:06.212: E/AndroidRuntime(27721):    ... 10 more

0 个答案:

没有答案