How To List All Apks With Isgame Flag Set To True?
I got this code: _pm = _context.PackageManager; List packageList = new List(); Intent intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.
Solution 1:
Ofcourse, I searched 2 days without an answer, and then finally decided to post a question here, and ofcourse now i found an answer.
_pm = _context.PackageManager;
List<string> packageList = new List<string>();
Intent intent = new Intent(Intent.ActionMain);
intent.AddCategory(Intent.CategoryLeanbackLauncher);
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);
}
}
What did I do? I saw, out of pure luck, that the ApplicationInfo variable ai, got a field Flags, that contain the correct flag, (not the flag FLAG_IS_GAME nor ApplicationCategories.Game)) also, I found the right class to pick the IsGame from (ApplicationInfoFlags.IsGame)
The rest is simple.
The conclusion, is that the approach to get the information about the app beeing a game or not about the category, or the FLAG_IS_GAME seems not to work as it should.
This worked for me, and hopefully the next guy in the same problem :)
Post a Comment for "How To List All Apks With Isgame Flag Set To True?"