Detect when the foreground application changes in android?
<p>My app is a service, and I want to do the different tasks according to the different foreground application.</p>

<p>I know that I could get the current foreground application info. by <code>ActivityManager.getRunningAppProcesses()</code>.</p>

<p>However, is there a way to detect when the foreground application changes without polling the foreground application info. periodically?</p>
