Google Play内购querySkuDetailsAsync接口未返回商品状态问题咨询
I totally get the frustration here—Google Play's SkuDetails object doesn't expose the active/inactive status of products directly, even digging into originalJson won't give you that field. Here are a few practical workarounds to achieve what you want:
Maintain a local/backend SKU status mapping
This is the simplest client-side approach. Create a static list or fetch a remote config that maps each SKU to its active status (you can sync this with your Play Console manually or via automation). For example:val skuStatusMap = mapOf( "premium_monthly" to true, // Active "premium_yearly" to false, // Inactive "basic_tier" to true )After fetching
SkuDetailsviaquerySkuDetailsAsync(), iterate through the list and cross-reference with this map. You can then filter out inactive SKUs entirely, or flag them to render with a grayed-out UI and "即将上线" label.Use the Google Play Developer API
For a more dynamic, automated solution, you can leverage the Google Play Developer API (note: this needs to run on your backend, not the client app, since it requires OAuth2 authentication). Theproducts.listendpoint returns each product'sstatusfield, which can beACTIVE,INACTIVE, orDRAFT.
Your backend can periodically fetch this data and expose an endpoint for your app to retrieve the latest SKU statuses. This way, you don't have to manually update a local map every time you change a product's status in the Play Console.Implement the display logic
Once you have the status info, adjust your UI accordingly:- To hide inactive SKUs: Filter the
SkuDetailslist before passing it to your adapter, removing any entries marked as inactive. - To show grayed-out items: In your adapter's
onBindViewHolder, check the SKU's status and apply a disabled style (lower opacity, gray text) along with a "即将上线" (Coming Soon) badge.
- To hide inactive SKUs: Filter the
Just a heads-up: If you go the local mapping route, make sure to keep it in sync with your Play Console changes—nothing's worse than showing an inactive product as available, or vice versa. For the Developer API approach, add caching on your backend to avoid hitting rate limits.
内容的提问来源于stack exchange,提问作者Russ Wheeler

