2016-11-11 62 views
0

對不起,這個問題,但我想篩選與權限名稱INTERNET應用列表過濾器的應用程序基於Internet的權限的Android

我該怎麼辦呢?

<uses-permission android:name="android.permission.INTERNET" /> 

試圖像這樣

PackageManager pm = context.getPackageManager(); 
     List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); 


      for (ResolveInfo ri : activities) { 
       ApplicationInfoclass info = new ApplicationInfoclass(); 

        // Add the non system package to the list 

        try { 
         PackageInfo pInfo = context.getPackageManager().getPackageInfo(ri.activityInfo.packageName, 0); 

        } catch (PackageManager.NameNotFoundException e) { 
         e.printStackTrace(); 
        } 

        info.packageName = ri.activityInfo.packageName; 
        info.name = (String) ri.loadLabel(pm); 
        info.icon = ri.activityInfo.loadIcon(pm); 
        apps.add(info); 


      } 
+0

獲取'PackageInfo',而不是'ApplicationInfo',並期待在'permissions'領域。 – CommonsWare

+0

你好,我打電話給PackageInfo pInfo = context.getPackageManager()。getPackageInfo(ri.activityInfo.packageName,0); 但權限標籤有不同的數據類型如何過濾互聯網任何代碼的幫助? – AndroidBeginnerJhon

回答

0
PackageManager pm = context.getPackageManager(); 
    for (ResolveInfo ri : pm.queryIntentActivities(intent, 0)) { 
     try { 
      PackageInfo packageInfo = pm.getPackageInfo(ri.activityInfo.packageName, 0); 
      for (PermissionInfo permissionInfo : packageInfo.permissions) { 
       if (permissionInfo.name.equals(Manifest.permission.INTERNET)) { 
        //package has internet permission, do something with it 
        break; 
       } 
      } 
     } catch (PackageManager.NameNotFoundException e) { 
      e.printStackTrace(); 
     } 
    } 
相關問題