startService 的隐式意图不安全 InAppPurchase

Implicit intents with startService are not safe InAppPurchase

我已经在我的应用程序中实现了应用内购买,但我遇到了这个问题

Implicit intents with startService are not safe: Intent { act=com.android.vending.billing.InAppBillingService.BIND } android.content.ContextWrapper.bindService:538 com.bulbulapps.bulbul.v3.BillingProcessor.bindPlayServices:106 com.bulbulapps.bulbul.v3.BillingProcessor.:99

我的代码:

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

但是该行正在生成警告 startService 的隐式意图不安全。

付款弹窗来了,付款也成功了,但是成功后没有到OnActivity结果

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        if (!bp.handleActivityResult(requestCode, resultCode, data))
            super.onActivityResult(requestCode, resultCode, data);

        Toast.makeText(getApplicationContext(), "onActivityResult", Toast.LENGTH_LONG).show();
}

我的要求是购买成功后必须办理

这样做:

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

仅使用显式意图来绑定服务,否则它将在 Android 5.0 及更高版本中抛出异常。

在 Android 5.0 之前也建议使用显式意图仅绑定服务。

The Context.bindService() method now requires an explicit Intent, and throws an exception if given an implicit intent. To ensure your app is secure, use an explicit intent when starting or binding your Service, and do not declare intent filters for the service.

检查此行为更改 here