获取Android开机启动项列表


 1 publicclass BootStartUtils {
2
3 privatestaticfinal String BOOT_START_PERMISSION ="android.permission.RECEIVE_BOOT_COMPLETED";
4
5 private Context mContext;
6
7 public BootStartUtils(Context context) {
8 mContext = context;
9 }
10
11 /**
12 * 获取Android开机启动列表
13 */
14 public List<Map<String, Object>> fetchInstalledApps() {
15 PackageManager pm = mContext.getPackageManager();
16 List<ApplicationInfo> appInfo = pm.getInstalledApplications(0);
17 Iterator<ApplicationInfo> appInfoIterator = appInfo.iterator();
18 List<Map<String, Object>> appList =new ArrayList<Map<String, Object>>(appInfo.size());
19
20 while (appInfoIterator.hasNext()) {
21 ApplicationInfo app = appInfoIterator.next();
22 int flag = pm.checkPermission(
23 BOOT_START_PERMISSION, app.packageName);
24 if (flag == PackageManager.PERMISSION_GRANTED) {
25 Map<String, Object> appMap =new HashMap<String, Object>();
26 String label = pm.getApplicationLabel(app).toString();
27 Drawable icon = pm.getApplicationIcon(app);
28 String desc = app.packageName;
29 appMap.put("label", label);
30 appMap.put("icon", icon);
31 appMap.put("desc", desc);
32
33 appList.add(appMap);
34 }
35 }
36 return appList;
37 }

  


  

posted @ 2011-08-09 18:34  水向东流  阅读(2205)  评论(0编辑  收藏  举报