问题描述
在项目中,我可以通过下面的code得到所有安装的应用程序的列表:
In my project I can get the list of all installed application by the following code:
public class ApplicationFilterActivity extends Activity implements
OnItemClickListener {
ListView appfilter;
SharedPreferences preferences;
public static String filenames = "RotateData";
PackageManager pck;
ArrayList<Applications> results = new ArrayList<Applications>();
ArrayList<String> gotPackagename = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
appfilter = (ListView) findViewById(R.id.lvApp);
preferences = getSharedPreferences(filenames, 0);
PackageManager packageManager = this.getPackageManager();
List<PackageInfo> applist = packageManager.getInstalledPackages(0);
Iterator<PackageInfo> it = applist.iterator();
while (it.hasNext()) {
PackageInfo pk = (PackageInfo) it.next();
results.add(new Applications(pk.applicationInfo
.loadIcon(packageManager), ""
+ pk.applicationInfo.loadLabel(packageManager)));
Log.i("AppName", "" + pk.applicationInfo.packageName);
gotPackagename.add(pk.applicationInfo.packageName);
}
appfilter.setAdapter(new Customarrayadapter(this, results));
appfilter.setOnItemClickListener(this);
}
}
但现在我想以过滤列表中只显示游戏,这可能吗?
but now I want to filter that the list will show only the games , is it possible?
推荐答案
有没有办法设置你的应用程序在Android的游戏类型,所以你不能按类别筛选应用程式。
There is no way to set your app as "Game Type" in Android, so you could not filter apps by category.
我认为,最好的解决办法 - 解析所有游戏包(游戏名可能是因为手机的定位不同)从谷歌播放,并把该列表中的应用程序,有时从你的服务器更新。如果你总是有你的应用程序的网络连接,你可以发送发现应用程序列表,服务器和服务器将从列表中返回背靠背比赛。所以,你需要编写服务器code表示。
I think, best solution - to parse all games packages (game name could be different because of phone localization) from Google Play and put that list in app and sometimes update it from your server. If you always got internet connection in your application you could send found apps list to server and server will return back games from that list. So, you need to write server code for that.
这篇关于如何以编程方式获取android系统已安装的游戏列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!