2
I’m finishing a college job where an app should present a splash screen and then a login screen. I would like it, as soon as the splash screen was finished, it would go out of history.
The structure is as follows: S (splash) -> L (Login) -> R (rest of the system). The history is as follows: S, L, R. I would like it to be just L, R, because when the user returns to the login screen, the application must close.
The code of the splash screen is this:
package activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import br.bravosix.tarefas.R;
public class SplashActivity extends Activity implements Runnable {
private Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.layout_splash);
mHandler.postDelayed(this, 1500);
}
@Override
public void run() {
Intent login = new Intent(this, LoginActivity.class);
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(login);
}
}
Use the flag Intent.FLAG_ACTIVITY_CLEAR_TOP
, suggested as solution in other questions, not solved.
Quick answer and still solved my problem! Thanks! (I still can not accept the answer, but as soon as I can accept).
– Renan Lazarotto