Android Question kill the last activity

Discussion in 'Android Questions' started by yaniv hanya, Jul 10, 2019.

  1. yaniv hanya

    yaniv hanya Member Licensed User

    Is there any way to cause the activity to be destroyed after calling startActivity. So that the next time i start it it will start from Activity_Create not form the Activity_Resume
     
  2. MarcoRome

    MarcoRome Expert Licensed User

    In this example you have 3 activity, Main, act_due, act_tre
    The main call act_due, if you click button open act_tre, if you click on button ( in act_tre ) reopen act_due and so...
    Look this code. If you have this code in act_due:

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("lay_due")
        
    If FirstTime Then
            
    Log("First Time DUE")
        
    Else
            
    Log("Run Again Activity_create DUE")
        
    End If
        
    End Sub


    Sub Button1_Click
        
    StartActivity(act_tre)
    End Sub
    When you click on button act_tre reopen act_due the Activity_create it ISNT executed, but it will go directly to Resume
    if you write this code:

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("lay_due")
        
    If FirstTime Then
            
    Log("First Time DUE")
        
    Else
            
    Log("Run Again Activity_create DUE")
        
    End If
        
    End Sub


    Sub Button1_Click
        
    StartActivity(act_tre)
        
    Activity.Finish ' <--------------- LOOK THIS
    End Sub
    When you click on button act_tre reopen act_due the Activity_create you see message in Log windows "Run Again Activity_create DUE" because in this cases Activity_create is executed with FirstTime = False
    Anyway i don't see any reason, since you can manage everything in Pause / Resume
     

    Attached Files:

    BillMeyer, José J. Aguilar and Erel like this.
  3. yaniv hanya

    yaniv hanya Member Licensed User

    Thank you very much that's exactly what I was looking for
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice