Close all Activities

3

I have 3 activities:

  • splash_screen
  • MainActivity
  • error_webview

activity error_webvie has two buttons, one to open the splash_screen and another to close (Exit), but wanted to click "Exit" activities and the application did not open.

Below the source code of my error_webview for anyone who can help me.

package conectaluziania.conectaluziania;

import android.app.Activity;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import prosportacademia.prosportacademia.MainActivity;
import prosportacademia.prosportacademia.R;
import prosportacademia.prosportacademia.splash_screen;

public class error_webview extends Activity {

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

/*Abre uma nova atividade Caso a internet não funcione*/
        OnClickListener listnr=new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i= new Intent("splash_screen");
                startActivity(i);
            }
        };
        Button btn =(Button) findViewById(R.id.button);
        btn.setOnClickListener(listnr);

/*Fim da Abertura da Atividade */

/*Inicio: Fecha a atividade quando clicar em Sair */

/*Fim: Fecha a atividade quando clicar em Sair */




    }
}
    
asked by anonymous 14.08.2016 / 18:47

1 answer

0

You have an example here [SOLUTION 2] that explains exactly what you want to know!

Another way, if it were to close the activity and the application, could be:

finish();
System.exit(0);

in the button listener.

    
15.08.2016 / 00:11