wuyxhero / marketbilling

Automatically exported from code.google.com/p/marketbilling
0 stars 0 forks source link

Null pointer in IABHelper on Kindle Fire #149

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Got a null pointer when testing on a Kindle Fire. Fixed it using the code 
below. Sorry for the wet (not DRY) code.

IABHelper.java Lines 267 onwards:

Intent serviceIntent = new 
Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
List<ResolveInfo> ri = 
mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
if (ri != null) {
            if (!ri.isEmpty()) {
                // service available to handle that Intent
                mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
            } else {
                // no service available to handle that Intent
                if (listener != null) {
                    listener.onIabSetupFinished(
                            new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                                    "Billing service unavailable on device."));
                }
            }
} else {
            // no service available to handle that Intent
            if (listener != null) {
                listener.onIabSetupFinished(
                        new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                                "Billing service unavailable on device."));
            }
}

Original issue reported on code.google.com by duane.ma...@gmail.com on 16 Oct 2013 at 3:25

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Out of the box, kindle fires use amazon IAP sdk , not google's.

Original comment by petetan...@gmail.com on 16 Oct 2013 at 7:41

GoogleCodeExporter commented 8 years ago
This was a result of an online test service so I assumed this device didn't
use Google's service. I was just submitting the extra code for the null
pointer check in so other users don't run into this issue.

I have to say, thanks for this code, it's helped a lot. For a developer who
has no clue about billing it's helped a lot. I just have to understand the
security now.

Cheers, Duane.

Original comment by duane.ma...@gmail.com on 16 Oct 2013 at 9:19

GoogleCodeExporter commented 8 years ago
Thanks for this fix... the logic can be cleaned up so you only need to change 
two lines:

        Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        serviceIntent.setPackage("com.android.vending");
        List<ResolveInfo> ri = mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
        if (ri != null && !ri.isEmpty()) {
            // service available to handle that Intent
            mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
        }
        else {
            // no service available to handle that Intent
            if (listener != null) {
                listener.onIabSetupFinished(
                        new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                        "Billing service unavailable on device."));
            }
        }

Original comment by georgie...@gmail.com on 1 Nov 2013 at 1:28

GoogleCodeExporter commented 8 years ago
Got the same problem on the emulator without the play services being installed.
Workaround from #4 solved it.

Original comment by hannes.b...@gmail.com on 28 Nov 2013 at 11:17

GoogleCodeExporter commented 8 years ago
Thanks #4, fixed issues for devices without Google Play Services.

Original comment by twig.ngu...@gmail.com on 8 Dec 2013 at 11:48

GoogleCodeExporter commented 8 years ago
thanks#4,fixed issues for devices without Google Play Services

Original comment by whbullet...@gmail.com on 6 May 2014 at 12:59