1

I want to retrieve the list of purchased items for my application. We only have the getPurchases API to do that. Its documentation says:

Because the Google Play client now caches In-app Billing information locally on the device, you can use the Version 3 API to query for this information more frequently, for example through a getPurchases call. Unlike with previous versions of the API, many Version 3 API calls will be serviced through cache lookups instead of through a network connection to Google Play, which significantly speeds up the API's response time.

However, it is not clear from that statement if that method can potentially perform a network call in order to retrieve the info. If that is the case, my app will crash as for now I call that method from the UI Thread only.

Is it safe to call that method from the UI Thread?

  • I would imagine the billing library's lookup is already async, that message appears more to inform you that often it is able to respond QUICKER due to the caches is all – Broak Feb 19 '17 at 22:19
  • getPurchases returns a Bundle. So, if it can be async, that means the main thread will be blocked until the Bundle is returned which is not what I want. I wonder if I need to go over the trouble of spawning a new thread and call that method inside this new thread then. That is why I need to know if getPurchases can perform asynchronous tasks. – Bitcoin Cash - ADA enthusiast Feb 19 '17 at 22:22

1 Answers1

0

In the end I've decided to play safe and use RxJava to spawn a thread and send the result back to the main thread instead. Even if it is the case today that that method does not perform a network call I don't want to assume it will always be that way since the docs really don't say anything about it.