Android Question Activity.Finish issue

joneden

Active Member
Licensed User
Longtime User
Hi All,

After calling Activity.Finish I return to my dashboard activity but then opening the activity again has the FirstTime flag in Activity_Create set to false. So it seems that the activity wasn't destroyed in the Activity.Finish call.

Should I do something different that Activity.Finish or is there a way to start the activity and force the FirstTime to be true? I've been using StartActivity to get it running...

Thanks for any pointers

Regards

Jon
 

joneden

Active Member
Licensed User
Longtime User
Got you :)

Thinking about it I do already use that method with the Material Drawer to avoid building a chain of past activities.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If you press the back button the current Activity will be finished, no need to catch the button and call Activity.Finish there.

Not quite. Imagine that you call from activity2, and Activity3 that is nothing but a form... you complete half the form, and in the way of doing it, you set a few variables... Now you hit the back Button, but you dont call activity.finish... You re-enter Activity3... althou the text fields may be empty, depending on your code, the previously set variables are unchanged (as opposed to being empty, null, or have a default value). This may cause your activity to produce results differently than if it had called activity.finish
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Seems to me that (optionally) more control should be handed to the developer so that when necessary we can properly kill off stuff not needed.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Not quite. Imagine that you call from activity2, and Activity3 that is nothing but a form... you complete half the form, and in the way of doing it, you set a few variables... Now you hit the back Button, but you dont call activity.finish... You re-enter Activity3... althou the text fields may be empty, depending on your code, the previously set variables are unchanged (as opposed to being empty, null, or have a default value). This may cause your activity to produce results differently than if it had called activity.finish
On close of Activity 3 Activity_Pause() is called.
On reenter Activity 3 Activity_Create() and Activity_Resume() is called.
Regardless if i hit the back button or call Activity.Finish.
Why should a variable value differ?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
imagine this, Activity3 is a set-up activity, where you define for example, a typeface for the text of some of your views.
now imagine that you set the typeface variable to a value from a dropdown list, but form no matter what reason, like a phonecall, sms, etc, a system app over-imposes itself over your app, sending your activity to background... still following me?
Imagine too that, you didn't feel necessary to create a failsafe feature in order to save the form current status if your activity loss focus. When re-entering your activity, the textfields will be empty, BUT the variables that where set, are still set to the values chosen before losing focus?

PS. maybe my example is a bit Odd...
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
This example is only a software design fault of the developer :rolleyes:
You should always save and restore the values of the entry fields in this case.
If the user must re-enter the data because of an interrupt he wish you (the developer) to hell ;)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
This example is only a software design fault of the developer :rolleyes:
You should always save and restore the values of the entry fields in this case.
If the user must re-enter the data because of an interrupt he wish you (the developer) to hell ;)

I agree, BUT it is the way it would behave if nothing is coded to prevent it....

as I said, it was an example... an odd one
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top