Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

android - onIabPurchaseFinished never called.

I've been trying to set up in-app billing for my first app, and have been using the android.test.purchased sku. The purchase come through, and I manage to get the SKU into my inventory, but, as the title says, onIabPurchaseFinished, is never called.

I think it may have something to do with this Log: "Couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@406743d0 has no id". That pops up, right before going of to Google Play. I'm not really sure what that means though...

Launching purchase:

mHelper.launchPurchaseFlow(this, sku, 10001, mPurchaseFinishedListener, "");

And the Listener:

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {

    @Override
    public void onIabPurchaseFinished(IabResult result, Purchase info) {
        System.out.println("Purchase Finish heard something");

        if (result.isFailure()) {
             Log.d(TAG, "Error purchasing: " + result);
             return;
        } else{
                Log.d(TAG,"Success!");
             }


    }
};
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding this to the Activity that calls mHelper.launchPurchaseFlow(..):

    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

    // Pass on the activity result to the helper for handling
    if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
        // not handled, so handle it ourselves (here's where you'd
        // perform any handling of activity results not related to in-app
        // billing...
        super.onActivityResult(requestCode, resultCode, data);
    }
    else {
        Log.d(TAG, "onActivityResult handled by IABUtil.");
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...