Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android 2 Application Development
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2010, 12:49 AM
Registered User
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Confused between onSaveInstanceState and onPause on page 81 and 82

It might be SDK version differences that results in different application of onSaveInstanceState and onPause methods.

This is my understanding of onSaveInstanceState() and onPause(), backed up by the explanation on
http://developer.android.com/intl/zh...#v=TkPiXRNee7A
found at 13 mins 50 sec mark.

1) onSaveInstanceState() is intended for the use to save UI states, I have no question about that.
2) onPause() is intended for the use to save persistent data (database, files.. etc), in other words.. data that should persist across application sessions.

If my understanding is correct, then shouldn't the comment in onStop() found on page 82
"Persist all edits or state changes ..." be moved to onPause() ?

thanks
Reply With Quote
  #2 (permalink)  
Old March 9th, 2010, 09:26 AM
Reto's Avatar
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

You make a good point! In most circumstances you will want to persist all edits and state changes on onPause to ensure that they are saved should the runtime prematurely kill the application while it's paused.

In practice, a paused Activity may still be visible, so there is a chance that some of its state may have changed (though not through direct user interaction). It's also very unlikely that a paused Activity (rather than a stopped one) will be executed.

In general though, you're 100% correct. That comment would be better placed in the onPause method. Thanks for the feedback!
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
onSaveInstanceState etc. Todd A BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 March 15th, 2009 04:18 PM
Confused About ManageArticles page pinch BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 14th, 2007 06:12 PM
Example code for EJB(ISBN:81-7366-351-3) akb_das Wrox Book Feedback 3 August 27th, 2004 03:49 PM
Exercise ch2, page 82 ssr All Other Wrox Books 2 September 10th, 2003 03:42 AM



All times are GMT -4. The time now is 01:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.