Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

RemoteException handling not supported #52

Copy link
Copy link
@larsa71

Description

@larsa71
Issue body actions

Hi,

I have a test-case where I simulate that the market is stopped in an purchase:

  1. Lunch a test app with a buy button. At this point I am connected with help of the android billing library
  2. I do a force stop on the "Market" application from the "Manage applications" settings
  3. This will generate a remote exception

The current implementation in BillingService.java looks like this:

private void runRequest(BillingRequest request) {
    try {
        final long requestId = request.run(mService);
        BillingController.onRequestSent(requestId, request);
    } catch (RemoteException e) {
        Log.w(this.getClass().getSimpleName(), "Remote billing service crashed");
        // TODO: Retry?
    }
}

So the question here is how to handle: "//TODO: Retry?"

Here is my suggestion in code, don't know if anyone else have a better fix or suggestion how to handle this?

Suggested improvements:

BillingService.java:

public void onServiceDisconnected(ComponentName name) {

    // Genxbit customization to handle the case when we are disconnected.

    // Ensure we're not leaking Android Market billing service
    if (mService != null) {
        try {
            unbindService(this);
        } catch (IllegalArgumentException e) {
            // This might happen if the service was disconnected
        }
    }

    mService = null;
}


private void runRequest(BillingRequest request) {
    try {
        final long requestId = request.run(mService);
        BillingController.onRequestSent(requestId, request);
    } catch (RemoteException e) {
        Log.w(this.getClass().getSimpleName(), "Remote billing service crashed");

        // Genxbit customization

        onServiceDisconnected(null);
        request.onResponseCode(ResponseCode.RESULT_ERROR);
    }
}


// Genxbit customization

public static boolean hasService() {
    return mService != null;
}

BillingController.java

public static BillingStatus checkBillingSupported(Context context) {

    // Genxbit customization

    if (status == BillingStatus.UNKNOWN || !BillingService.hasService()) {
        BillingService.checkBillingSupported(context);
    }
    return status;
}

So then for the retry this can be up to the actual individual implementation to handle in my case I use the the "onRequestPurchaseResponse" callback and in case for ResponseCode.RESULT_ERROR I just perform a BillingController.checkBillingSupported(applicationContext).

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.