In-App Billing v3, bindService() Intent can't be found

后端 未结 1 1919
庸人自扰
庸人自扰 2020-12-30 15:39

I am using in-app billing from Google for Android for the first time. However, if a user doesn\'t have an internet connection or no google framework installed (e.g. with cus

相关标签:
1条回答
  • 2020-12-30 16:05

    argh, found answer myself shortly after:

    You have to check if the intent receiver is available by implementing a method like suggested here: [can i use this intent - blogpost][1]

    (edit) However, this method needs some serious changes to be applicable for the billing-service, as the original method only checks for default intents, which is not what we want.

    however, my implementation looks like the following and seems to work, at least on those devices, specifications etc. i tested: (ONLY TESTED FOR V3 OF IN APP BILLING)

    public static boolean isBillingAvailable(Context context) {
        final PackageManager packageManager = context.getPackageManager();
        final Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        List<ResolveInfo> list = packageManager.queryIntentServices(intent, 0);
        return list.size() > 0;
    }
    
    0 讨论(0)
提交回复
热议问题