The purpose of the service must be explicit: Intent {act = com.android.vending.billing.InAppBillingService.BIND}

I get an explicit intentional exception on some 5.0 devices, however my code already has an explicit intent and looks like this:

Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    PackageManager pm=mContext.getPackageManager();
    List<ResolveInfo> intentServices = pm.queryIntentServices(serviceIntent, 0);
    if (intentServices != null && !intentServices.isEmpty()){
        //this was replaced per this comment http://stackoverflow.com/a/24202135/704836
    //if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).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."));
        }
    }

The exception that I get is the following:

Non-fatal Exception: java.lang.IllegalArgumentException
Service Intent must be explicit: Intent { act=com.android.vending.billing.InAppBillingService.BIND }

android.app.ContextImpl.validateServiceIntent (ContextImpl.java:1681)

android.content.ContextWrapper.bindService (ContextWrapper.java:538)

IabHelper.startSetup (IabHelper.java:272)

MyApp.createIABHelper (MyApp.java:256)

MyApp.onCreate (MyApp.java:156)

android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1011)

android.app.ActivityThread.handleBindApplication (ActivityThread.java:4520)

android.app.ActivityThread.access$1500 (ActivityThread.java:144)

android.app.ActivityThread$H.handleMessage (ActivityThread.java:1339)

android.os.Looper.loop (Looper.java:135)

android.app.ActivityThread.main (ActivityThread.java:5223)

java.lang.reflect.Method.invoke (Method.java)

com.android.internal.os.ZygoteInit.main (ZygoteInit.java:693)

I'm not sure what I'm doing wrong, every search I do brings serviceIntent.setPackage("com.android.vending");as a fix, but my code already has this.

Thank.

+4
source share
1 answer

Try to get the latest version of com.android.vending.billing.utils from the official site, you can solve this problem.

http://developer.android.com/training/in-app-billing/preparing-iab-app.html#GetSample

0

Source: https://habr.com/ru/post/1570928/


All Articles