I got this code:
_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);
var counter = 0;
foreach (var app in list)
{
counter++;
ApplicationInfo ai = _pm.GetApplicationInfo(app.ActivityInfo.PackageName, 0);
if (filter.Equals(IApplicationsControl.Filter.AppsOnly))
{
if (ai.Category != ApplicationCategories.Game)
{
Android.Util.Log.Debug("pm", counter + ". " + ai.Category + " - " + app.ActivityInfo.PackageName);
packageList.Add(app.ActivityInfo.PackageName);
}
}
}
The output:
1. Undefined - com.android.vending
2. Undefined - com.google.android.youtube.tv
3. Undefined - com.myApp.test1
4. Undefined - com.android.traceur
5. Undefined - com.arris.android.stb.rcu
6. Undefined - com.arris.upgradetest
7. Undefined - com.clearchannel.iheartradio.application.tvapplication
8. Undefined - com.ericsson.tv
9. Audio - com.google.android.music
10. Undefined - com.google.android.play.games
11. Undefined - com.uei.uassample
12. Undefined - com.FDGEntertainment.redball4.gp <--- this is a game
13. Undefined - com.fgol.HungrySharkEvolution <--- this is a game
14. Undefined - com.hyperkani.bomberfriends <--- this is a game
15. Undefined - com.madfingergames.deadtrigger2 <--- this is a game
16. Undefined - com.secretexit.turbodismount <--- this is a game
17. Undefined - com.vectorunit.purple.googleplay
I installed several games, such as Hungry Shark and DeadTrigger2, I opend the APKs and both applications got the isGame:true set in their AndroidManifest.xml files.
The code above is listing the categories of my apps as Undefined, this includes my 2 games, it's like that for nearly all of my apps, except some AUDIO app that plays music.
So, in the end, why does my code not work?
I was following this links:
How to check if the app is game or not programmatically?
Also, I found this one, that concerns me a lot:
How can check app is game or not android?
So in the end, is it even possible now to check if an app is a game or not?
My API lvl is 28+