title: Get application names with specific permission
body: <p>I want list of all applications installed on the device which use a specific permission like INTERNET.</p>
  
  <p>i am using this code , but not able to retrieve results , please help .</p>
  
  <pre><code>private ArrayList&lt;String&gt; getInstalledApps(Context context) {
      ArrayList&lt;String&gt; results = new ArrayList&lt;String&gt;();
      PackageManager packageManager = context.getPackageManager();
      List&lt;PackageInfo&gt; applist = packageManager.getInstalledPackages(0);
      Iterator&lt;PackageInfo&gt; it = applist.iterator();
      while (it.hasNext()) {
          PackageInfo pk = (PackageInfo) it.next();
          if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(Manifest.permission.INTERNET, pk.packageName))
              results.add("" + pk.applicationInfo.loadLabel(packageManager));
      }
  
      for (int i = 0; i &lt;= results.size(); i++) {
          Log.v("app using internet = ", results.toString());
      }
  
      return results;
  }
  </code></pre>