In an app I am developing I need to iterate through the installed apps and detect which ones are games. Is there any way to do this?
I was thinking to a Play Store
For me the above answer didn't work, the ApplicationInfo.FLAG_IS_GAME is now deprecated, with API 28+ (in my case), you can do something like this:
_pm = _context.PackageManager;
List packageList = new List();
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryLeanbackLauncher); // or add any category you want
var list = _pm.QueryIntentActivities(intent, PackageInfoFlags.MetaData);
foreach (var app in list)
{
ApplicationInfo ai = _pm.GetApplicationInfo(app.ActivityInfo.PackageName, 0);
var allFlags = ai.Flags;
if (allFlags.HasFlag(ApplicationInfoFlags.IsGame))
{
packageList.Add(app.ActivityInfo.PackageName);
}
}