when you intent activity from splash screen need to add FLAG_ACTIVITY_NEW_TASK,FLAG_ACTIVITY_CLEAR_TASK,FLAG_ACTIVITY_NO_ANIMATION
Intent mIntent = new Intent(context, mClass);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(mIntent);
finishActivity();
1)declare this variable globally
private boolean doubleBackToExitPressedOnce;
private Handler mHandler = new Handler();
2)Then Implement this 3 below method
--------------------------------
@Override
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
finish();
}
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
mHandler.postDelayed(mRunnable, 2000);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mHandler != null) {
mHandler.removeCallbacks(mRunnable);
}
}
@Override
protected void onResume() {
super.onResume();
this.doubleBackToExitPressedOnce = false;
}
private final Runnable mRunnable = new Runnable() {
@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
};