How to detect if an android app is a game?

前端 未结 3 1639
遇见更好的自我
遇见更好的自我 2020-12-11 09:54

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

3条回答
  •  独厮守ぢ
    2020-12-11 10:39

    This answer is deprecated!
    Correct and backwards compatible way to do this is here!

    Since Android API version 21, there's finally a way to check if an application is a game.

    PackageManager pm = mContext.getPackageManager();
    ApplicationInfo ai = pm.getApplicationInfo(mPackageName,0);
    if((ai.flags & ApplicationInfo.FLAG_IS_GAME) == ApplicationInfo.FLAG_IS_GAME)
        return true;
    return false;
    

提交回复
热议问题