我是仿照andorid launcher裡面的方法,現抽取如下:
- Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
- mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
-
- final PackageManager packageManager = getPackageManager();
- List<ResolveInfo> apps = null;
-
- apps = packageManager.queryIntentActivities(mainIntent, 0);
- mNameList = new ArrayList<String>();
- mDrawableList = new ArrayList<Drawable>();
- mNameList.clear();
- mDrawableList.clear();
- if(apps != null && apps.size() > 0)
- {
- for (int i = 0; i < apps.size(); i++)
- {
- mNameList.add((String) apps.get(i).loadLabel(packageManager));//獲取應用名稱
- mDrawableList.add(apps.get(i).loadIcon(packageManager)); //獲取應用圖片
- System.out.println(apps.get(i).loadLabel(packageManager));
- }
- }
這樣就可以過濾出category為Intent.CATEGORY_LAUNCHER的所有的應用了
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11