title: How to get installed packages in android?
body: <p>I can get my code to get all installed packages and display them in a toast. The problem is, I want my code to only display the package name containing a string  in it. How do I do that?</p>
  
  <pre><code>ActivityManager actvityManager = (ActivityManager)
      getApplicationContext().getSystemService( getApplicationContext().ACTIVITY_SERVICE );
  List&lt;RunningAppProcessInfo&gt; procInfos = actvityManager.getRunningAppProcesses();
  
  for(int pnum = 0; pnum &lt; procInfos.size(); pnum++)
  {
   if((procInfos.get(pnum)).processName.contains("android")||    (procInfos.get(pnum)).processName.contains("system")||(procInfos.get(pnum)).processName.contains("huawei")||(procInfos.get(pnum)).processName.contains("adil")) 
   {
        //Toast.makeText(getApplicationContext(), "system apps", Toast.LENGTH_SHORT).show();
   }
  else
  {
      actvityManager.killBackgroundProcesses(procInfos.get(pnum).processName);
      Toast.makeText(getApplicationContext(), "killed "+procInfos.get(pnum).processName, Toast.LENGTH_SHORT).show();
  
  }
   }
  </code></pre>