7

I have an android application that works like restriction of some Apps categories like game. so if i stop all game apps in my android device then how its possible. how i get this app is game OR weather OR Medical etc.

Any ideas....

3 Answers 3

4

Application categories correspond to a classification in Android Market, but not something you can check on the application itself. What you can do is to query the Android Market for information of a specific application.

Android Market identifies applications by package name. So get an ApplicationInfo for the package you want to query about (check PackageManager documentation) and use ApplicationInfo.packageName.

Then query Android Market about the package name you just got. Here's a non-official API http://code.google.com/p/android-market-api/

Hope it helps.

2
  • How can i compare this, means day by day android market is update then how can i manage? Dec 21, 2011 at 9:41
  • I am afraid that you can not monitor updates in Market with this API, but you can cache the results and re-check from time to time. Generally it is safe to assume the category will not change. Although it is possible, it is unlikely.
    – gimix
    Dec 21, 2011 at 10:41
3

Create a raw JSON POST request, with an array of the packages you want to categorize:

{
  "packages": [
    "com.pixmix.mobileapp",
    "snooze.ninja"
  ]
}

Send it to:

http://api.wheredatapp.com/data

And here's the response:

{
    "apps": [
        {
            "category": "Photography",
            "created": 1430868349,
            "package": "com.pixmix.mobileapp"
        },
        {
            "category": "Productivity",
            "created": 1427510152,
            "package": "snooze.ninja"
        }
    ]
}
1

I know that this a very old question, but it still shows high when searching. I just answered a similar question here https://stackoverflow.com/a/61801271/7274401, so I'll copy it below.

API level 26 (O) has added categories to android.content.pm.ApplicationInfo. From the docs https://developer.android.com/reference/android/content/pm/ApplicationInfo#category:

public int category

The category of this app. Categories are used to cluster multiple apps together into meaningful groups, such as when summarizing battery, network, or disk usage. Apps should only define this value when they fit well into one of the specific categories.

Set from the R.attr.appCategory attribute in the manifest. If the manifest doesn't define a category, this value may have been provided by the installer via PackageManager#setApplicationCategoryHint(String, int). Value is CATEGORY_UNDEFINED, CATEGORY_GAME, CATEGORY_AUDIO, CATEGORY_VIDEO, CATEGORY_IMAGE, CATEGORY_SOCIAL, CATEGORY_NEWS, CATEGORY_MAPS, or CATEGORY_PRODUCTIVITY

One can now do something like:

PackageManager pm = context.getPackageManager();
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
    int appCategory = applicationInfo.category;
    String categoryTitle = (String) ApplicationInfo.getCategoryTitle(context, appCategory)
    // ...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.