Search code examples
androidin-app-purchaseandroid-billingnetworkonmainthreadandroid-inapp-purchase

Android - In app billing V3. Is it safe to call getPurchases on the UI thread at all times?


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?


Solution

  • 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.