如何检测,如果Android应用程序是一个游戏? [英] How to detect if an android app is a game?

查看:1235
本文介绍了如何检测,如果Android应用程序是一个游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个应用程序,我开发我需要遍历安装的应用程序,并发现哪些是游戏。有没有办法做到这一点?

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?

我在想一个Play商店的API,它可以搜索软件包的名称,并返回其类别,即使它仅限于在商店的应用程序。有没有类似的东西存在?是否有可能?

I was thinking to a Play Store API that can search for package name and returns its category even if it's only limited to apps on the store. Does something similar exist? Would it be possible?

有没有任何其他办法做到这一点?

Is there any alternative way to do it?

推荐答案

由于Android的API版本21,还有最后一种方法来检查,如果一个应用程序是一个游戏。

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;

这篇关于如何检测,如果Android应用程序是一个游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆