1

In my application there are 4 activities. 1-LoginOrSignupActivity(Main) 2-SignupActivity 3-LoginActivity 4-MainFeedActivity

Problem is that when i am logged in and i am in MainFeedActivity if i press back but it takes me back to loginOrSignupActivity. I want my application to go on onPause State when back button is pressed within MainFeedActivity.

Flow is like LoginOrSignupActivity->LoginActivity->MainFeedActivity

other flow is like LoginOrSignupActivity->SignupActivity->MainFeedActivity

i used this Flag but still it is not working

 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
SimoV8
  • 1,382
  • 1
  • 18
  • 32
Zeeshan Shabbir
  • 6,704
  • 4
  • 38
  • 74

1 Answers1

1

If you first go to LoginOrSignup, then LoginActivity, and then open MainActivity, you need to call finish() on your passed activities when you move on. Or else the activity will remain in the back stack. Alternatively you can set a flag on your activity in the manifest.

Relevant reading: http://developer.android.com/guide/components/tasks-and-back-stack.html

For those cases where you don't want the user to be able to return to an activity, set the element's finishOnTaskLaunch to "true" (see Clearing the stack).

Kenneth
  • 3,957
  • 8
  • 39
  • 62
  • I have tried that finish(); method but it causes another problem let me explain that to you. Lets suppose if user goes to login activity and then he wants to go back to LoginOrSignup activity and he presses back up then app will close instead of going back. – Zeeshan Shabbir Sep 06 '15 at 08:34
  • Should i call finish() in LoginAcitivity. Where i use intent to start Main Activity? and yes i used CLEAR_TOP flag – Zeeshan Shabbir Sep 06 '15 at 08:40
  • There are numerous threads on this matter at SO, for example http://stackoverflow.com/questions/11308198/start-new-activity-and-finish-current-one-in-android – Kenneth Sep 06 '15 at 08:45
  • Thanks. I can't 1+ you. otherwise i would have. It worked :) – Zeeshan Shabbir Sep 06 '15 at 08:54