Question

I'm currently working on an app that lists all purchased apps (Like "Purchased Apps" in Google Play Store). Is there a solution to get a list of app that contains in app billing ? How can we know if an app has been purchased or not ? Is a rooted phone needed for this ?

Thanks.

Was it helpful?

Solution

To get the list of installed applications supporting in-app billing, you can check for their permissions:

final List<PackageInfo> inAppBillingEnabledPackages = new ArrayList<PackageInfo>();
final PackageManager pm = getPackageManager();
final List<PackageInfo> installedAppInfo = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (final PackageInfo packageInfo : installedAppInfo) {
    if (packageInfo.requestedPermissions != null) {
        for (final String permissionInfo : packageInfo.requestedPermissions) {
            if ("com.android.vending.BILLING".equals(permissionInfo)) {
                inAppBillingEnabledPackages.add(packageInfo);
            }
        }
    }
}
// inAppBillingEnabledPackages now contains a list of packages supporting in-app billing

This works fine with a non-rooted phone.

As for "purchased apps", do you mean which installed apps have been paid for and are not free ? If so, for apps downloaded from Play, since I don't think the Play app supports any such Intent, I guess the only way would be to get the price of the app (which will depend on the country !) from an API like the ones listed in this SO thread, for example here's an example of how to get the price info in a given locale using android-market-api.

OTHER TIPS

Most likely this is not possible. What you can still try is to use standard call to query all products with an empty list of products. It works for application owning these products. I've never tried whether it works for any application, but you can give it a try.

// must be initialized first
IInAppBillingService service; 

// query products
Bundle skusBundle = new Bundle();
skusBundle.putStringArrayList("ITEM_ID_LIST", new ArrayList<String>());
Bundle response = service.getSkuDetails(3, "<package name>", "inapp", skusBundle);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top