获取安装的应用程序的列表,方便。但如何启动其中的一个? [英] Getting list of installed app's, easy. But how to launch one of them?

查看:166
本文介绍了获取安装的应用程序的列表,方便。但如何启动其中的一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个应用程序将只是一种发射器,我想改善。
该发射器将推出定制的家​​庭用户已安装。

My first application will just be a kind of launcher that I would like to improve. This launcher will launch a custom Home that the user has installed.

这就像应用首页切换,但我想这样做我自己。

That's like the application "Home Switcher, but I would like to do that myself.

所以我的第一个目标是让所有家的应用程序列表:真的很容易和code是有:

So my first goal is to get all "Home" applications list: that's really easy and the code is there:

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 
pm=getBaseContext().getPackageManager();
mainIntent.addCategory(Intent.CATEGORY_HOME); 
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent,0);

现在我想这样做,在ListView。我的第一个问题是让图标:我失败了​​,但是这不是我的主要问题(如果你能帮助我,我会很高兴)

Now I would like to do that in a listview. My first problem is to get the Icon: I failed, but that's not my main problem ( if you can help me I would be happy)

我成功做一个列表视图与安装的家庭的所有名称:

I succeed to make a listview with all the names of the installed Home:

for(...){
    map = new HashMap<String, String>(); 
    map.put("titre",info.activityInfo.applicationInfo.loadLabel( pm ).toString());
    map.put("pck",info.activityInfo.packageName);
    listItem.add(map);
}
    SimpleAdapter homeAdapter = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.row,
    new String[] {"img", "titre"}, new int[] {R.id.img, R.id.titre});
    myListView.setAdapter(homeAdapter);

现在,当我点击一个家,我想发动家庭,所以我所做的是:

And now when I click on a home, I would like to launch the Home, so what I did is:

protected void onListItemClick(ListView l, View v, int position, long id) {
 super.onListItemClick(l, v, position, id);

 HashMap<String, String> map = (HashMap<String, String>) myListView.getItemAtPosition(position);
 Intent myIntent = new Intent();
 myIntent.setPackage(map.get("pck"));
 startActivity(myIntent);  

}

所以,存在着出现,并问我一个盒子:

So, there is a box that that appear and ask me:

完成操作:
   的LauncherPro - 或者检测 - 或ADW
   Wallaper画廊

Complete action using: LauncherPro - or Sense - or ADW Wallaper Gallery

我想我靠近,我想做些什么,但我想我失去了一些东西,我是谁?

I think I am close to what I would like to do, but, I think I'm missing something, am I?

推荐答案

下面是一个示例项目实施发射式的活动。

这篇关于获取安装的应用程序的列表,方便。但如何启动其中的一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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