When to start and stop the In-App Billing service?

A simple question, which I, however, cannot solve: when should I start and stop the billing service? I think of two solutions:

  • starting with onCreate and stopping at onDestroy
  • starting at onResume and stopping at onPause

What is the best practice? Thanks in advance.

+6
source share
1 answer

I would suggest that your billing service be received from IntentService, so that it starts / stops automatically when necessary. You start it using startService (Intent), and then when it finishes, it will shut down. IntentService also provides a built-in queue, so only one intention will be processed immediately, as well as its own workflow.

As I recall, you also need a receiver to use the IAB, which can then call the service using Intent and set the action based on what needs to be done.

0
source

Source: https://habr.com/ru/post/891704/


All Articles