시작 관련

2784 단어
//              
    public List listBootApps() {
        List bootAppNames = new ArrayList();
        PackageManager pm = mFragment.getActivity().getPackageManager();
//       App   
        List appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
        for (ApplicationInfo appInfo : appInfos) {
            if (appInfo.packageName.equals("com.zzc_trackingreact")) {

                int i = ContextCompat.checkSelfPermission(mFragment.getActivity(), Manifest.permission.RECEIVE_BOOT_COMPLETED);

//                if (ContextCompat.checkSelfPermission(mFragment.getActivity(), Manifest.permission.RECEIVE_BOOT_COMPLETED)
//                        != PackageManager.PERMISSION_GRANTED) {
//                    //     ,           。
//                }else{
//                    //     。
//                }

                Log.d("     ", appInfo.toString());
                int iBoot = pm.checkPermission("android.permission.RECEIVE_BOOT_COMPLETED", appInfo.packageName);
                if (iBoot == PackageManager.PERMISSION_GRANTED) {
                    String appName = pm.getApplicationLabel(appInfo).toString();
                    bootAppNames.add(appName);
                }
            }
        }
        return bootAppNames;
    }

    private void getPermissions() {
        PackageManager packManager = mFragment.getActivity().getPackageManager();
        List infos = packManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
//      App  
        for (ApplicationInfo info : infos) {
            if (info.packageName.equals("com.zzc_trackingreact")) {
                Log.d("app", "appName--->" + packManager.getApplicationLabel(info) + "");
                try {
                    PackageInfo packInfo = packManager.getPackageInfo(info.packageName, PackageManager.GET_PERMISSIONS);
                    String permissons[] = packInfo.requestedPermissions;
//   app     
                    int length = permissons.length;
                    for (int i = 0; i < length; i++) {
                        Log.d("app", permissons[i]);
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
//                    e.printStackTrace();
                }
            }

        }
    }

    private void getPermission(){
        ComponentName localComponentName = new ComponentName(mFragment.getActivity(), WakeReceiver.class);
        int i = mFragment.getActivity().getPackageManager().getComponentEnabledSetting(localComponentName);
    }

좋은 웹페이지 즐겨찾기