应用内结算v3,无法找到bindService()Intent

时间:2012-12-18 13:01:01

标签: android in-app-purchase in-app-billing

我首次使用Google for Android进行应用内结算。但是,如果用户没有连接互联网或没有安装谷歌框架(例如使用自定义roms),可能还有其他场合(如错误/旧市场版本等) 这个方法(在提供的IabHelper类中):

        mContext.bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                         mServiceConn, Context.BIND_AUTO_CREATE);

不起作用,也没有建立服务。使用“活动管理器”中的小调试信息:

12-17 19:58:31.184: W/ActivityManager(76): Unable to start service Intent { act=com.android.vending.billing.InAppBillingService.BIND }: not found

有没有人找到任何方法以有意义的方式“捕获”此错误,或者检查Intent / Package是否可用的任何解决方法?

提前致谢。

1 个答案:

答案 0 :(得分:9)

argh,发现后不久回答:

您必须通过实施此处建议的方法来检查意图接收器是否可用: [我可以使用这个意图 - 博文] [1]

(编辑)但是,这种方法需要进行一些严格的更改才能适用于计费服务,因为原始方法只检查默认意图,这不是我们想要的。

然而,我的实现看起来像以下似乎工作,至少在那些设备,规格等我测试:(仅测试应用程序中的V3付费)

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