How to remove an activity from a the stack
<p>I am making an application in which i want to make sure that only one instance of a single activity should remain in the stack.Please tell me how to achieve that.This is the coding which i was trying but have not got the intended result.</p>

<pre><code>ArrayList&lt;String&gt; runningactivities = new ArrayList&lt;String&gt;();

    ActivityManager activityManager = (ActivityManager)getBaseContext().getSystemService (Context.ACTIVITY_SERVICE); 

    List&lt;RunningTaskInfo&gt; services = activityManager.getRunningTasks(Integer.MAX_VALUE); 

        for (int i1 = 0; i1 &lt; services.size(); i1++) { 
            runningactivities.add(0,services.get(i1).topActivity.toString());  
        } 

        if(runningactivities.contains("ComponentInfo{com.velosys.interview_preparation/com.velosys.interview_preparation.activities.MCQ}")==true){
             Toast.makeText(getBaseContext(),"Activity is in foreground, active",1000).show(); 
            //MCQ.
        }
</code></pre>

<p>Thanks in advance</p>
