Removing SurfaceView from the application stack
<p>Hello StackOverflow Users,</p>

<p>I am new to android and trying to develop a game in which I use a </p>

<p>1) Main class to redirect (like a menu.. new game, options, help, exit etc..)</p>

<p>2) A surfaceview class</p>

<p>3) A thread to handle drawing on canvas.</p>

<p>I have added an exit button on the main class. </p>

<p>However after playing the game i.e. drawing the objects and using them, when i redirect to my Main class and try to exit; the main screen disappears but the view and threads aren't destroyed.</p>

<p>This is the main class.</p>

<pre><code>package com.tgm.welcome;

import com.tgm.R;
import com.tgm.main.GThread;
import com.tgm.main.TGMActivity;
import com.tgm.options.OptionsMain;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class Welcome_Act extends Activity {

    ImageView game, exit, options;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);

        game = (ImageView) findViewById(R.id.newGame);
        options = (ImageView) findViewById(R.id.options);
        exit = (ImageView) findViewById(R.id.exit);


        game.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                gotogame();
            }
        });

        options.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
            goto_opt(); 

            }
        });


        exit.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                exit_game();
            }
        });
    }



    public void gotogame() {
        Intent game = new Intent(Welcome_Act.this, TGMActivity.class);
        startActivity(game);
    }

    public void goto_opt() {
        Intent opt = new Intent(Welcome_Act.this, OptionsMain.class);
        startActivity(opt);
    }

    public void exit_game() {

        System.exit(0);
    }

}
</code></pre>

<p>PLEASE HELP TO REMOVE THE GAMESCREEN FROM THE STACK THAT ANDROID MAINTAINS.</p>

<p>Thanks..</p>
