2

我的第一个应用程序只是一种我想改进的启动器。此启动器将启动用户已安装的自定义主页。

这就像应用程序“Home Switcher,但我想自己做。

所以我的第一个目标是获取所有“家庭”应用程序列表:这真的很简单,代码就在那里:

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

现在我想在列表视图中做到这一点。我的第一个问题是获得图标:我失败了​​,但这不是我的主要问题(如果你能帮助我,我会很高兴)

我成功地制作了一个包含已安装主页的所有名称的列表视图:

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);

现在当我点击一个主页时,我想启动主页,所以我所做的是:

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);  

}

因此,出现了一个框并问我:

使用:LauncherPro - 或 Sense - 或 ADW Wallaper Gallery 完成操作

我想我已经接近我想做的事情了,但是,我想我错过了一些东西,是吗?

4

1 回答 1

4

这是一个实现启动器样式活动的示例项目。

于 2010-07-20T19:32:05.150 回答