Android ActivityManager showing every 2 secs that the application is open?
<p>Can anyone please help me ?<br>Here is my alarmmanager code that will open up the service after every 2 seconds..</p>

<pre><code>AlarmManager alarmManager = 
    (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
    calendar.getTimeInMillis(), 2*1000 , pintent);
</code></pre>

<p>And here is my code for checking running application</p>

<pre><code>ActivityManager activityManager = (ActivityManager) 
    this.getSystemService( ACTIVITY_SERVICE );
List&lt;RunningAppProcessInfo&gt; procInfos = activityManager.getRunningAppProcesses();
for(int i = 0; i &lt; procInfos.size(); i++){
   if((procInfos.get(i).processName.equals("com.android.browser") 
        &amp;&amp; procInfos.get(i).importance==procInfos.get(i).IMPORTANCE_FOREGROUND)) {
           Toast.makeText(getApplicationContext(), "Browser is running",
                 Toast.LENGTH_LONG).show();
</code></pre>

<p>The problem is that when the browser is open a toast appears every 2 secs. How should I make this appear only once as the browser gets foreground ? Really need some help </p>

<p>Thank You !</p>
