tags:

views:

104

answers:

2

Hi all,I am confused about activity lifecycle usage in the notepad example,notepad example use "edit in place" user model,inserting new record in onCreate method, saving persistent state in onPause method,and save away the original text in onSaveInstanceState method. I am a J2EE programer,I can not understand the logic described above. why not make things simple as following:

1.Not inserting new record in onCreate method. 2.When user pressing BACK,it is equal as pressing save button in the editorform,so execute inserting or updating in onPause method if activity.isFinishing() is true. don't persiste use data if activity.isFinishing() is not true. 3.Not save the original text in onSaveInstanceState method,It is no necessary.If the activity is killed and back,restore user inputing data in the editorForm is adequately.

I think this logic is more traditional and natural. Maybe I not understand the essence of the activity lifecycle.Please air your's opinion.

Thanks

L.J.W

+1  A: 

Hi L.J.W.,

the lifecycle of an adroid app under various conditions (e.g. switching screens, freezing, stopping etc.) is described in an excellent video tutorial by google. You may also want to refer to the slides of that talk, in particular, slide 16ff may be of great interest for you.

In any case you are right in thinking that understanding the lifecycle of an android app is the key to coding for android.

S.Tayefeh
+1  A: 

Hi Tayefeh,Thanks for your reply and supply excellent slides.But anybody answer my question directly?about "edit in place" in notepad example I mentioned.

L.J.W