私の最初のアプリケーションは、改善したい一種のランチャーになります。このランチャーは、ユーザーがインストールしたカスタム ホームを起動します。
それが「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
自分のやりたいことに近づいたと思いますが、何かが足りないと思いますよね?