Google Lollipop 的播放许可库问题

Google Play Licensing Library issue with Lollipop

我使用此页面中的许可证检查代码:

How to license my Android application?

并希望它也适用于 Lollipop。错误是:

java.lang.IllegalArgumentException: Service Intent must be explicit

不幸的是,这是 Google Play 许可库的 known bug。该问题已分配,将在未来修复,与此同时,如果您还想将库与 Lollipop 一起使用,则有一个解决方法:

在LicenseChecker.java中从这个改变:

boolean bindResult = mContext.bindService(new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                                          this, // ServiceConnection.
                                          Context.BIND_AUTO_CREATE);

对此:

Intent serviceIntent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
serviceIntent.setPackage("com.android.vending");

boolean bindResult = mContext.bindService(serviceIntent),
                                          this, // ServiceConnection.
                                          Context.BIND_AUTO_CREATE);