Application does not exit after pressing notification
<p>I started a notification with the code as follows. If i start the Notification from an app with a button, it will start but if i press an 'Exit' button on the same App it will clear the Notification and exit.</p>

<p>However, if i close the App after the Notification up start the app again with the Notification using a PendingIntent. The App 'Exit' button will clear the Notification, but will not exit the app unless it is pressed again.</p>

<p>How can i develop it to clear Notification and exit, regardless of how the App in opened.</p>

<p>Can any one help please, What is wrong with this code?</p>

<pre><code>public void onClick(View v) {

    switch (v.getId()) {
    case R.id.bStat:
        Intent intent = new Intent(this, NotifyActivity.class);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
        String body = "This is a Test..";
        String title = "XxxXxx Xxxxx..";
        Notification n = new Notification(R.drawable.ttsn, body,
                System.currentTimeMillis());
        n.setLatestEventInfo(this, title, body, pi);
        n.defaults = 0;
        // Notification.DEFAULT_ALL
        nm.notify(uniqueID, n);
        break;

    case R.id.bExit:
        nm.cancel(uniqueID);
        finish();
        break;
    }

}
</code></pre>
