Android如何获取开机启动项列表

 static final String BOOT_START_PERMISSION = "android.permission.RECEIVE_BOOT_COMPLETED";
 

  public List<Map<String, Object>> fetch_installed_apps(){
         List<ApplicationInfo> packages = getPackageManager().getInstalledApplications();
         list = new ArrayList<Map<String, Object>>(packages.size());
         Iterator<ApplicationInfo> appInfoIterator = packages.iterator();
      
 
         while (appInfoIterator.hasNext()) {
             ApplicationInfo app = (ApplicationInfo) appInfoIterator.next();
            //查找安装的package是否有开机启动权限
            if(PackageManager.PERMISSION_GRANTED==
                          getPackageManager().checkPermission(BOOT_START_PERMISSION, app.packageName))
             {
                   String label = getPackageManager().getApplicationLabel(app).toString(); 
                   Drawable appIcon = getPackageManager().getApplicationIcon(app);
                   Map<String, Object> map = new HashMap<String, Object>();
                   map.put("name", label);
                   map.put("desc", app.packageName);
                   map.put("img",appIcon);
                   list.add(map);             
             }
          }
         return list;
  }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。