在应用程序内结算V3,bindService()目的无法找到 [英] In-App Billing v3, bindService() Intent can't be found

查看:303
本文介绍了在应用程序内结算V3,bindService()目的无法找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的应用内计费,从谷歌对于Android的第一次。但是,如果用户没有连接到互联网或没有安装谷歌框架(例如,使用自定义光盘),可能其他场合(如错误/老市场版等) 这种方法(提供IabHelper类中):

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?

在此先感谢。

推荐答案

哎呀,发现后不久,回答自己:

argh, found answer myself shortly after:

您必须检查是否意图接收器可通过实施喜欢这里提出了一个方法: [我可以用这个目的 - 博文] [1]

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.

不过,我的实现如下所示,似乎工作,至少在这些设备,规格等我测试:(只测试了用于在应用程序内结算V3)

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;
}

这篇关于在应用程序内结算V3,bindService()目的无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆