p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 (http://p2p.wrox.com/forumdisplay.php?f=432)
-   -   Chapter 2 -- To Do List -- when to use super.onCreate(icicle);? (http://p2p.wrox.com/showthread.php?t=72014)

SteveOliverC December 30th, 2008 03:36 PM

Chapter 2 -- To Do List -- when to use super.onCreate(icicle);?
 
Eclipse sets up a new Android project with onCreate and includes super.onCreate(savedInstance) as the first line. I see this in the sample code I downloaded, but don't see it on page 40 of the book.

Without this line, the debugger throws a "source not found" error.

My question is, Where is onCreate that we are overriding? and why do we need to do this (was this supposed to be included in page 40)?

thanks.

dflipb December 30th, 2008 07:37 PM

I'm getting the same error. What is the problem?

Reto December 31st, 2008 03:37 AM

Quote:

Originally Posted by SteveOliverC (Post 232298)
My question is, Where is onCreate that we are overriding? and why do we need to do this (was this supposed to be included in page 40)?

Apologies! Yes, it looks like the super.onCreate(icicle) line somehow got dropped from the text on page 40 -- you always need to call super.OnCreate when overriding the onCreate method of an Activity. It should be the first thing called in the overriding method.

The correct technique for overriding onCreate is shown on page 66, or as you point out, in the downloadable code samples.

Sorry again for the confusion, not sure how that snuck through.

SteveOliverC December 31st, 2008 11:27 AM

No worries! and thanks for the quick reply and clarification. I'm really enjoying the book and I am very impressed with the quality (especially considering how quickly the book came to market).

dflipb December 31st, 2008 11:58 AM

Just one more question about icicle. What is icicle and why do I change savedInstance to icicle?

I also agree this book is fantastic. Thank you.

Reto January 1st, 2009 01:49 PM

'icicle' is what earlier versions of the SDK used to name the Bundle objects that got passed in to the onCreate method. The new SDK defaults the name to savedInstanceState. I've used them interchangeably, but for consistency it's probably easiest to stick with savedInstanceStatein your own projects.

It's great to hear you guys are finding the book useful, thanks for the kind words.

eags January 5th, 2009 10:42 PM

Worked for me...
 
The eclipse plugin automatically inserted that line for me and I guess I didn't even notice since I had already seen it in other examples. I was wondering about the random use of the term icicle however so thanks for the clarification.


All times are GMT -4. The time now is 11:22 PM.

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