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....
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.
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"
}
]
}
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
, orCATEGORY_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)
// ...
}