'Check if a subscription has been purchased android

How can I check if a user purchased a subscription on Google Play Billing ? I tried to test on a test subscription "android.test.purchased" with this code :

            val purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.INAPP)
            Log.d("showResult", purchasesResult.getPurchasesList().toString());

but i always get an empty list, how can i check if the user has purchased a subscription?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source