Android - 应用内结算 V3。始终在 UI 线程上调用 getPurchases 是否安全?
Android - In app billing V3. Is it safe to call getPurchases on the UI thread at all times?
我想为我的应用程序检索已购买项目的列表。我们只有 getPurchases
API 可以做到这一点。它的 documentation 表示:
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.
但是,从该声明中不清楚该方法是否可以潜在地执行网络调用以检索信息。如果是这种情况,我的应用程序将崩溃,因为现在我仅从 UI 线程调用该方法。
从 UI 线程调用该方法安全吗?
最后我决定安全起见,使用 RxJava 生成一个线程并将结果发送回主线程。即使今天的情况是该方法不执行网络调用,我也不想假设它永远都是那样,因为文档真的没有说明任何事情。
我想为我的应用程序检索已购买项目的列表。我们只有 getPurchases
API 可以做到这一点。它的 documentation 表示:
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.
但是,从该声明中不清楚该方法是否可以潜在地执行网络调用以检索信息。如果是这种情况,我的应用程序将崩溃,因为现在我仅从 UI 线程调用该方法。
从 UI 线程调用该方法安全吗?
最后我决定安全起见,使用 RxJava 生成一个线程并将结果发送回主线程。即使今天的情况是该方法不执行网络调用,我也不想假设它永远都是那样,因为文档真的没有说明任何事情。