Implicit intents with startService are unsafe. InAppPurchase

I have implemented In-app purchase in my application and I am facing this problem

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

My code:

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

      

but this line generates a warning. Implicit intents with startService are unsafe.

Payment popup coming and payment is also successful, but after success it does not come to OnActivity result

@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();
}

      

My requirement is that I have to process after a successful purchase.

+3


source to share


1 answer


Do it like this:

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

      

Use explicit intent for service binding only, otherwise it will throw an exception in Android 5.0 and up.



Prior to Android 5.0, it was also suggested to use explicit intent for service binding only.

The Context.bindService () method now requires an explicit intent and throws an exception if an implicit intent is specified. To keep your application safe, use explicit intent when you start or bind your Service, and don't declare intent filters for the service.

Check out this behavior change here .

+3


source







All Articles