compare variable value inside an android service
<p>I am running a service which checks which application is currently running in the foreground. the following code provides the currently foreground app name .</p>

<pre><code>ActivityManager activityManager = (ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE);
ListappProcesses=activityManager.getRunningTasks(1);

//get foreground App name 
 foregroundApp=appProcesses.get(0).topActivity.getPackageName();
</code></pre>

<p>Now I put this piece of code inside a service . the service checks every 15 secs if the foreground app has changed .the foreground variable updates if the foreground app changes . How can I compare when the value of foregroundApp variable changes ??</p>
