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

Aee*_*ire 5 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);
Run Code Online (Sandbox Code Playgroud)

不起作用,没有服务得到确立.使用"活动管理器"中的小调试信息:

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

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

提前致谢.

Aee*_*ire 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;
}
Run Code Online (Sandbox Code Playgroud)