开发者

Android activity history stack problem

开发者 https://www.devze.com 2023-01-13 13:20 出处:网络
In my application, I have problem with activity history stack. Indeed, consider I have 5 activities :

In my application, I have problem with activity history stack. Indeed, consider I have 5 activities :

  1. Splashscreen
  2. SignUp
  3. SignIn
  4. ForgottenPassword
  5. Home

I would see :

  • First launch (user not logged) : 3 differents wireframes possible
    • Splashscreen -> SignUp -> H开发者_高级运维ome
    • Splashscreen -> SignUp (already member) -> SignIn (valid log) -> Home
    • Splashscreen -> SignUp (already member) -> SignIn -> ForgottenPassword (login/password receive by mail)-> SignIn (valid log) -> Home
  • Other launch (user registered) : Splashscreen -> Home (auto log)

The problem is : I would like 2 tasks, one with Splashscreen, SignUp, SignIn and ForgottenPassword and an other with Splashscreen and Home. Why ? Because back from Home should close the application but go back to previous activity (SignUp or SignIn according wireframe). Define activity with history=true on SignUp and SignIn do that but does not allow ForgottenPassword -> SignIn and SignIn -> SignUp :(

Thanks for your help


There a couple of ways to do this, one way:

Whenever you start the Home activity, use startActivityForResult. When the home activity exits (user hits back), the previous activity will be notified. If you don't want that activity to be shown, immediately finish that activity. You can use the request or result codes to help you determine if you want to show the activity again.

I belive you can also do something like this:

startActivity(homeActivityIntent);
finish();

to remove the previous activity from the stack when you start the home activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消