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 custom roms) and probably other occasions (like wrong/old market version etc.) This method (inside the provided IabHelper class):
mContext.bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
Doesn't work and no service get's established. With a small debugging information from "Activity Manager":
12-17 19:58:31.184: W/ActivityManager(76): Unable to start service Intent { act=com.android.vending.billing.InAppBillingService.BIND }: not found
Has anyone found any way to "catch" this error in a meaningful way, or any workaround to check if the Intent/Package is available?
Thanks in advance.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With