title: How to get installed package name in a list?
body: <p>I am new in android.I had to retrieve list of all installed application package names using the following code</p>
  
  <pre><code>    List&lt;PackageInfo&gt; packages = getPackageManager().getInstalledPackages(0);
      for(PackageInfo pack : packages)
      {
          ActivityInfo[] activityInfo = getPackageManager().getPackageInfo(pack.packageName, PackageManager.GET_ACTIVITIES).activities;
          Log.i("Pranay", pack.packageName + " has total " + ((activityInfo==null)?0:activityInfo.length) + " activities");
          if(activityInfo!=null)
          {
              for(int i=0; i&lt;activityInfo.length; i++)
              {
                  Log.i("PC",""+ activityInfo[i]);
                  myList = new ArrayList();
                  myList.add(pack.packageName);
  
              }
              aplist = new ArrayList&lt;String&gt;();
              aplist.add(pack.packageName);
              Toast.makeText(this, "list are      "+aplist, Toast.LENGTH_LONG).show();
  
          }
  
  
      }
  </code></pre>
  
  <p>but it gets the packagename in diff toast. How Can I get all package name in a single list ??</p>