android: how do I know if the home screen is in focus
<p>I have an service running on android and I need to know if is any application on focus or if the "desktop" (home screen) is in focus. I don't know if this is the proper word to refer to the home screen of the phone. How can I know if this is in focus or some other application?</p>

<p>Inside the service I have this code to get the running tasks:</p>

<pre><code>ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
// get the info from the currently running task
List&lt;ActivityManager.RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1);
ComponentName componentInfo = taskInfo.get(0).topActivity;
</code></pre>

<p>How can I know from componentInfo if this is desktop or no? On emulator the componentInfo.getPackageName() returns <strong>com.android.launcher</strong> but in a galaxy s1 (I tested only in this phone) returns something else.</p>

<p>There is any other way to do this?</p>

<p>Thanks.</p>
