title: how to show array list in listView android?
body: <p>How do i display a list of apps having this permission in a list view? </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>I have found a code <a href="https://stackoverflow.com/questions/13026257/get-application-names-with-specific-permission">here</a>, but i don't know how to show that in my list view? any help will be highly appreciated! :D</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 ((pk.applicationInfo.flags &amp; ApplicationInfo.FLAG_SYSTEM) != 0) {
              Log.v("system app using internet = ", ""+pk.applicationInfo.loadLabel(packageManager));
              continue;
          }
          if (PackageManager.PERMISSION_GRANTED == packageManager
                  .checkPermission(Manifest.permission.INTERNET,
                          pk.packageName))
              results.add("" + pk.applicationInfo.loadLabel(packageManager));
      }
  
      Log.v("app using internet = ", results.toString());
  
      return results;
  }
  </code></pre>
  
  <p>here is my main activity with my listview </p>
  
  <pre><code>    package com.example.antivirus;
  
      import android.app.Activity;
      import android.os.Bundle;
      import android.widget.ArrayAdapter;
      import android.widget.ListView;
  
      public class MainActivity extends Activity {
  
          // Array of strings...
          String[] mobileArray = { "Android", "IPhone", "WindowsMobile",
                  "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X" };
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              ArrayAdapter adapter = new ArrayAdapter&lt;String&gt;(this,
                      R.layout.activity_listview, mobileArray);
  
              ListView listView = (ListView) findViewById(R.id.mobile_list);
              listView.setAdapter(adapter);
          }
      }
  </code></pre>