I have an activity where a user put his nickname. I want to not be able to go back after this. I have tried everything but no luck. Tried so far :
Manifest
<activity
android:name=".NewUserActivity"
android:noHistory="true" />
<activity android:name=".PvP.PVPWinningActivity" />
In Activity:
btnEnterDungeons.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!TextUtils.isEmpty(editUsername.getText().toString().trim())) {
uploadUserData();
Intent intent = new Intent();
intent.setClass(NewUserActivity.this, GameChooseActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
finish();
}
or in Activity again:
btnEnterDungeons.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!TextUtils.isEmpty(editUsername.getText().toString().trim())) {
uploadUserData();
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setClass(NewUserActivity.this, GameChooseActivity.class);
startActivity(intent);
finish();
}
None of these works. Actually, I want to completely kill the activity, no back button or any way to have access again.
In NewUserActivity, override OnBackPressed() method then call finish; to kill the current activity; See sample implementation below:
@Override public void onBackPressed() {
killActivity();
})
.setNegativeButton("No", null)
.show();
}
private void killActivity() {
finish();
}