1. Download our Official Android App: Forums for Android!

Apps Question about android hierarchy

Discussion in 'Android Development' started by Jelmerholland, Mar 28, 2011.

  1. Jelmerholland

    Jelmerholland Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Feb 17, 2011

    Feb 17, 2011
    8
    0
    5
    Dear developers,


    I have a question about the hierarchy of Android.

    I have the following structure:

    • SplashScreen.java (LAUNCHER)
      • Menu.java (DEFAULT)
        • InstrumentList.java (DEFAULT)
          • Instrument.java (DEFAULT)
    Okay, for this question it doesn't matter what I am creating but I have to tell you that I have 2 types of 'InstrumentList', and those are: "snare" and "wind".

    Now, you have a list (depending on which button you pressed) everything works fine. That's not the problem. Now, when you press on a listitem (instrument) you get a detailed 'information package' of it. Off course you can go 'back'.

    so: SplashScreen > Menu > InstrumentList > Instrument
    and when you go back: Instrument > InstrumentList
    and even further: InstrumentList > Menu

    What I want to do is finish() the InstrumentList activity when you go back to Menu. But I don't want it to be finish()'ed when you go to to Instrument.
    So when do I have to use the finish() function? In the onPause() part? No, because when you are in InstrumentList and go to Instrument, the InstrumentList is finish()'ed. And I don't want that.

    So my question is, when you go back to the parent activity (Menu), is the child (InstrumentList) automatically finish()'ed? Or do I have to do this manually? The problem is that I don't want to have 20 activities open by accident (in child>child>child activities)

    I hope that you guys understand what I want and that you can attempt to help me.


    Kind regards, Jelmer
     

    Advertisement

  2. pietjuhhh1990

    pietjuhhh1990 Well-Known Member
    Rank:
    None
    Points:
    38
    Posts:
    235
    Joined:
    Feb 21, 2011

    Feb 21, 2011
    235
    22
    38
    App/web development
    Netherlands
    Mabey an onKeyPress with the back button when your in the certain list space
     
  3. Jelmerholland

    Jelmerholland Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Feb 17, 2011

    Feb 17, 2011
    8
    0
    5
    So, if I understand you correctly, the Activity doesn't finish() when you go 'back' ?
     
  4. RazzleFnDazzle

    RazzleFnDazzle Well-Known Member
    Rank:
    None
    Points:
    58
    Posts:
    123
    Joined:
    Sep 30, 2010

    Sep 30, 2010
    123
    15
    58
    If I understand your question correctly you want to make sure when you use the back button the activity you are currently on is destroyed and cleaned up to prevent your from using too much memory. If this is your question then yes it should be. If you want to verify add a log to onDestroy to see it is called.
     
    Jelmerholland likes this.
  5. Jelmerholland

    Jelmerholland Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Feb 17, 2011

    Feb 17, 2011
    8
    0
    5
    Thanks. That was exactly the answer I was looking for :)
     
  6. pietjuhhh1990

    pietjuhhh1990 Well-Known Member
    Rank:
    None
    Points:
    38
    Posts:
    235
    Joined:
    Feb 21, 2011

    Feb 21, 2011
    235
    22
    38
    App/web development
    Netherlands
    It is nessesery to close multi useage objects (the camera for instance)
    Android system will do the rest
     

Share This Page

Loading...