4
I own 3 activities:
splash_screen
MainActivity
error_webview
To Activity error_webview
has two buttons, one to open the splash_screen
and another to close (Exit), but wanted to click on "Exit" to close all activities and the app wasn’t open.
Below the source code of mine 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 */
}
}
If the app is for Android 4.1(Api 16) or higher you can use finishAffinity()
– ramaral