activity launch mode and navigation


Last Updated:

  1. emistral

    emistral New Member This Topic's Starter

    Joined:
    Jul 13, 2009
    Messages:
    3
    Likes Received:
    0
    Hi all,

    This is my first post and I am not sure it is the correct forum for this thread.
    If not, could someone move it to the appropriate forum? Thanks

    Here is my question:
    I am currently coding a strategy board game. Because of the nature of the game, the first activity is a splash screen where time consuming tasks are performed. The splash screen has a progress bar.
    When the tasks are completed, I start the next activity ( the main menu for the game) with an intent and call finish() on the splash screen to destroy it since I do not need it anymore.
    The main menu has several options, one of them is "start game".
    I should mention that I want only one instance of each activity and not multiple ones.

    My question is related to the navigation between activities.
    When the game has started, if I press the home key then from the home screen I long press the home button and select the game.
    The game reopened where I left it which is fine
    However if I relaunch the application from the application launcher, it will relaunch the splash screen and seems to have destroyed the game that was been played.
    This is not the behaviour that I want. I was expecting to restart the activity from where it stopped even if I relaunch it via the app launcher.
    I must specify that all activities have the default launch modes.
    I have tried to change the launch mode of the splash screen activity to singletask but it is even worse. Whether I try to select my app from the long press home or via the app launcher - after the game has started - it goes back to the splash screen.

    It seems I can not find the correct way to define those activities.
    Basically what I want is:

    Splashscreen opened the first time the activity starts then destroyed and start menu activity.
    Then whether I relaunch the activity via the app launcher or long press home key, I want to go back where I was.
    And all activities need to be only one instance
    If someone could help me, that would be much appreciated.
    Thanks
     

    Advertisement
  2. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    Once your app is no longer visible, you cannot be certain it's still running in the background; it may be stopped or killed by the OS.

    Therefore, you should hook into the activity life cycle events to ensure your game maintains its state. You may need to re-run the loading screen, even if you're resuming an ongoing game.

    You might also want to juggle around your activities, so the 'Back' button works on the app as a whole, as opposed to working on each individual activity within your app -- but this may clash with the user's expectations and needs to work 'just right' to avoid alienating your users. You could do this by having one 'main' activity which is itself invisible but spawns or relays between sub-activities.
     
  3. sundarv

    sundarv New Member

    Joined:
    Dec 28, 2010
    Messages:
    2
    Likes Received:
    0
    Hi Emistral,

    I too have the same issue. Could you tell me how to solve it?

    Thanks in Advance.
    Sundar
     

Share This Page

Loading...