0

I don't want user to be able to go somewhere back from my LoginActivity.

This works nice from MainActivity (from Navigation Drawer):

Intent intent = new Intent(this, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();

Result - back stack is cleared.
But when I'm trying to call this from my custom Dialog:

private Context mContext;
Intent intent = new Intent(mContext, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
dismiss();
mContext.startActivity(intent);
((Activity)mContext).finish();

back stack isn't clear, I can go back from my LoginActivity to previous window.

Tried to search the reason, but no result till now.

Goltsev Eugene
  • 3,325
  • 6
  • 25
  • 48

2 Answers2

0

I had a similar problem and adding android:launchMode="singleTop" to my activity in AndroidManifest.xml did the work.

I took the idea from this question

Community
  • 1
  • 1
theBittor
  • 786
  • 1
  • 11
  • 20
0

Try clearing your activity stack:

Set android:noHistory= "true" in your AndroidManifest.xml file in the <activity tag for the login activity.

http://developer.android.com/reference/android/R.styleable.html#AndroidManifestActivity_noHistory

CodeShane
  • 6,480
  • 1
  • 18
  • 24
SUNIL GOWROJI
  • 143
  • 1
  • 2
  • 12