how to check "Is there any application in foreground or not" programmatically
<p>I am developing an application, in which i want to check that is there any application is in foreground or not. I can get the list of running Apps through this code:</p>

<pre><code>List&lt;PackageInfo&gt; list = pm.getInstalledPackages(0);

procInfos = actvityManager.getRunningAppProcesses();
for (int i = 0; i &lt; procInfos.size(); i++) 
{
            runningApplist.add(procInfos.get(i).processName);
            runningApplistpid.add(procInfos.get(i).pid);
}
</code></pre>

<p>now i can get the foreground application by sorting this list. But how to check is there any app in foreground or not
Also..... we can check that our app is in forground or not by this:</p>

<pre><code>public Boolean foregroundAppgetter()
 {
    boolean check = false;
    for (RunningAppProcessInfo appProcess : procInfos)
    {
       if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND)
       {
         check = true;
        }

     }
     return check;
  }
</code></pre>

<p>But what about other Applications?</p>
