Programming Android

Errata for Programming Android

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page &ŕ
1st paragraph

Images on pages 10 and 11 of printed version are not correct. More details : Page 10 ; Figure 1-3 : "The Eclipse Add Site dialog" => actual image shows the SDK and AVD Manager (same than Figure 1-2 at page 9) Page 11 ; Figure 1-4 : "The Eclipse Install New Software dialog with the Android Hierarchy Viewer plug-in showed as available" => actual image shows the SDK and AVD Manager (same than Figure 1-2 at page 9)

Note from the Author or Editor:
The image on pp10 is incorrect

Franco Bergomi  Sep 17, 2011  Sep 30, 2011
PDF
Page 1
1st paragraph

The 2nd to last word 'Android' is incorrectly written as 'Andorid'.

Note from the Author or Editor:
Will be fixed during copy edit

Derek Rodger  Jan 25, 2011 
Printed
Page 5
2nd paragraph

"javac _version" did not work for my system. "java -version" did. (Windows 7 64 bit)

Note from the Author or Editor:
the release version does not suggest using an underscore. Still, using java instead of javac is probably an improvement.

Anonymous  Mar 08, 2012 
PDF
Page 10
Figures 1-3 & 1-4

Figures 1-3 & 1-4 are totally wrong and are actually copies of figure 1-2

Note from the Author or Editor:
Confirmed. The figs are all duplicates. This has been fixed already.

Anonymous  Sep 15, 2011 
PDF
Page 11
In the Workspace paragraph

"A workspace is a folder containing set of Eclipse projects" that should probably be 'sets' or 'a set'

Note from the Author or Editor:
This will get fixed during copy edit

Derek Rodger  Jan 25, 2011 
Other Digital Version
13
2nd paragraph

It would be nice to expand on the package name field so that a developer might pick a good name as far as what they should do for testing and eventual deployment to end users.

Note from the Author or Editor:
Hah! I knew this was a good idea! I just added it yesterday.

Parick TenHoopen  Jan 31, 2011 
Other Digital Version
18
5th paragraph

In the section "Running a program on an Android Device" you mention that if you are running Linux, you will need to create a "rules" file. Farther down you provide the link, but only mention the link in relation to USB debugging. I think you might want to explicitly mention that the link describes how to setup the 'rules' file. Turning on USB debugging is really only one small step as part of setting up Linux to work with a device.

Note from the Author or Editor:
WIll leave this around in case someone gets a chance to address it...

Derek Rodger  Jan 25, 2011 
Other Digital Version
23
2nd paragraph

When launching DDMS in Eclipse Helios SR1, it is listed under "Other" under the Window > Open Perspective menu.

Note from the Author or Editor:
We need to verify this!

Parick TenHoopen  Jan 31, 2011 
PDF
Page 24
4th paragraph (not counting the caution box)

The last sentence in the paragraph reads: "You should seethe welcome screen shown in Figure 1-1" There needs to be a space between 'seethe'.

Note from the Author or Editor:
Will be fixed during copy edit

Derek Rodger  Jan 25, 2011 
PDF
Page 31
4th paragraph

"interactive" is mispelled "interactice"; here's the incorrect line "where interactice client Java is going".

Note from the Author or Editor:
yeah, it's a typo

Ben Matteson  Jan 25, 2011 
PDF
Page 39
1st paragraph

I'm not sure, but maybe symmetry and not reflexivity should be mentioned here. So overriding equals() this way violates symmetry and not reflexivity?

Note from the Author or Editor:
We should change this. While the statement is correct (reflexivity is broken), it is symmetry that is more obviously broken and we should say so.

Ali L.  Nov 04, 2011 
Printed
Page 46
Top of the page

In the implementation of the service() method of the TemplatedService() class, there should be a semicolon after the runService() method call.

Note from the Author or Editor:
The semicolon is missing in the code at the top of page 46, the last line of the service() method.

Thomas Weisbach  Oct 03, 2011 
Printed
Page 50
1st paragram

In the example describing the behavior of thrown exceptions, the text states that "control returns to getActions"; however, the uncaught exception which occurs in readPageFromNet() would cause control to be returned to the caller of readPageFromNet(), which is getPage() (not getActions()).

Note from the Author or Editor:
fixed

Karen Schaefer  Dec 23, 2012 
PDF
Page 59
public class AccessibleStranger

The code contains the following line: target.subtypeAccess = "success!!"; // ERROR!! This isn't technically incorrect, but could be confusing. It probably was intended to read: target.subtypeAccess = "fail!!"; // ERROR!! Great book! Thanks, Will Lynch

Note from the Author or Editor:
Change "success!!" to "fail!!"

William Lynch  Oct 12, 2011 
Printed
Page 123
3rd Para

The books says that 3 static analysis tools are covered, however it then only goes on to describe FindBugs.

Note from the Author or Editor:
We expected to have a section on Checkstyle and perhaps PMD. We'll add them in the next edition.

Steve Webb  Oct 27, 2011 
Printed
Page 151
2nd paragraph

"Because the parameter vals is passed into the initButton method in the previous example (Figure 6-1),..." The figure, 6-1, is not the previous example. That code does not have an initButton method.

Note from the Author or Editor:
Confirmed. Text is incorrect

Walter Falby  Dec 15, 2011 
PDF
Page 153
3rd comment // runs on the UI thread

// runs on the UI thread @Override public void onInitProgress(int pctComplete) { publishProgress(Integer.valueOf(pctComplete)); } onInitProgress will be called from beneath doInBackgroud so that it doesn't run on the UI thread. But, the comment is // runs on the UI thread. It should be // runs on the background thread.

Note from the Author or Editor:
While the onProgressUpdate method runs on the UI thread, the onInitProgress method does not. The comment is in error.

Emerson Wang  Nov 10, 2011 
Printed
Page 154
1st and 2nd paragraphs

In the first paragraph, a call to bar.setStatus is mentioned. That line of code is not in the example. In the second paragraph, a method named publishProgress is mentioned. That method is not in the example.

Note from the Author or Editor:
Yep. .setStatus should be .publishProgress

Walter Falby  Dec 15, 2011 
PDF
Page 160
Top paragraph

"The marshaler's job is to write everything necessary to reconstruct the object state to the passed Parcel. Typically , this will mean expressing the object state in terms of the six primitive data types: byte, double, int, float, long, and String. " The String is not a primitive data type.

Note from the Author or Editor:
This is accurate, though splitting hairs

Andy  Dec 25, 2011 
Safari Books Online
181-182
final Dots dotModel = new Dots();

The variable dotModel is defined but never used in the code listing. Also on Pg 182, while defining the interface method onDotsChange(..) Dots d is passed in as parameter. In the method body, Dot d = dots.getLastDot(); is defined. There seem to be typos. I think the variable name is wrongly defined ... there is no definition for dots in the class. Should we be changing the line: final Dots dotModel = new Dots(); to final Dots dots = new Dots(); AND pubic void onDotsChange(Dots d) to public void onDotsChange(dots) Make more sense ? Pls correct me if I am wrong. It changed my perception of what you are passing into the interface method called and the underlying concept being explained ?? Thanks, B Rgds Rajive

Note from the Author or Editor:
On pp 182, I do not believe that dotsModel is incorrectly named. The parameter to onDotsChange should be "dots", not "d"

Rajive Jain  Sep 22, 2011  Sep 30, 2011
PDF
Page 182
3rd line

3rd line on page 182: dots.setDotsChangeListener(new Dots.DotsChangeListener() { dots should be dotModel and the above line should be as follows: dotModel.setDotsChangeListener(new Dots.DotsChangeListener() {

Note from the Author or Editor:
yep

Emerson Wang  Dec 05, 2011 
PDF
Page 184
2nd paragraph

According to the declaration on page 181, i.e., final Dots dotModel = new Dots(); dots in the following line on page 184 should be dotModel: dots.addDot(event.getX(), event.getY(), Color.CYAN, DOT_DIAMETER); i.e., the above line should be as follows: dotModel.addDot(event.getX(), event.getY(), Color.CYAN, DOT_DIAMETER);

Note from the Author or Editor:
yeah...

Emerson Wang  Dec 05, 2011 
Printed
Page 190
5th Para

'It is may me' should read 'It may be'

Note from the Author or Editor:
Booring....

steve Webb  Oct 31, 2011 
PDF
Page 197
3rd paragraph, 3rd sentence

Text reads "introduced a new a feature". The second "a" should be removed.

Note from the Author or Editor:
whatever

None  Nov 23, 2011 
Printed
Page 204,206
Canada

On page 204, the factory method in the source code listing is named "createInstance". Lower down when using this factory in SimpleFragment's onCreate method, you call it "newInstance" instead. On page 206, you also use "newInstance".

Note from the Author or Editor:
verified

Kimon Niflis  Nov 30, 2011 
Printed
Page 254
first example

The example code: UPDATE contacts SET height_in_meters = 10, last_name = "Jones" should end with a semi-column. This would make it consistent with all the other example SQL statements in the book.

Note from the Author or Editor:
mmm.... We should be consistent, but I'm not sure which way...

Kimon Niflis  Dec 15, 2011 
PDF
Page 258

Based on the insert and update statements in pages 257 & 258 and the query results, the following SELECT statement selects the wrong column description: Finally, let’s delete a record using its ID: sqlite> DELETE FROM video WHERE _id = 1; sqlite> SELECT _id, description FROM videos; 2|Epic Fail Bicycle 3|Epic Fail Wagon 4|Epic Fail Sidewalk 5|Epic Fail Motorcycle In order to get the above query results, the SELECT statement should be as follows: SELECT _id, title FROM videos;

Note from the Author or Editor:
The text is showing the title, not the description.

Emerson Wang  Dec 14, 2011 
Printed
Page 262
2nd text line

States there are two important constants, however four are shown.

Note from the Author or Editor:
yep. "two" should be "four"

Steve Webb  Nov 09, 2011 
Printed
Page 263
in the last sentence of the section about the method onCreate

The method 'createVideosTable' is mentioned. However, in the code sample this refers to there is no such method. The method 'createTable' was the method probably intended. This mistake is repeated on the top of page 264.

Note from the Author or Editor:
I've named the method back to "createVIdeosTable", I think thats better, so now the text is correct...

Thomas Weisbach  Nov 17, 2011 
Printed
Page 263
in the section on the method 'onUpdate'

The method 'onUpdate' is mentioned, but there is no such method. Instead the method 'onUpgrade' is probably intended. This method is referred to three times in this paragraph, including one time on the subsequent page. Also, in this paragraph the class 'SimpleVideoContentProvider' is mentioned. However, 'SimpleVideoDbHelper' is probably what was intended.

Note from the Author or Editor:
yep

Thomas Weisbach  Nov 17, 2011 
PDF
Page 263
2nd paragraph

The YouTubeDbHelper class in the following sentence has never been mentioned before in the book: The onCreate method in the YouTubeDbHelper class shows one way to create the database. I guess that YouTubeDbHelper should be replaced with SimpleVideoDbHelper.

Note from the Author or Editor:
Confirmed

Emerson Wang  Dec 15, 2011 
PDF
Page 263
Last paragraph

The onUpgrade method for SimpleVideoDbHelper is very simple: it deletes the database. When the provider tries to use it later, Android will call the onCreate method because it does not exist The above statements didn't match the following onUpgrade method defined on page 262: public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldv, int newv) { sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + VIDEO_TABLE_NAME + ";"); createTable(sqLiteDatabase); } onUpgrade method deletes the database and then calls createTable() to create the database. Thus, Android won't call the onCreate method because it exists already.

Note from the Author or Editor:
The "Thus" might be confusing?

Emerson Wang  Dec 15, 2011 
Printed
Page 263
last paragraph

The last paragraph incorrectly makes (several) references to the "onUpdate" method. I believe it is actually intending to reference the "onUpgrade" method instead.

Note from the Author or Editor:
exactly correct. fixed in release

Anonymous  Mar 06, 2012 
Printed
Page 267

The streetview calls have been deprecated and there is now a different mechanism to get streetview working. So the streetview menu in the app no longer works.

Note from the Author or Editor:
Looks like this is true. We probably will need to update the example.

steve Webb  Nov 10, 2011 
PDF
Page 290
example code

The Finch Video Example does not work, I have found two Issues: a) The update Script for the database is wrong: Class FinchVideoContentProvider aroudn line 100 @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldv, int newv) { sqLiteDatabase.execSQL("DROP TABLE IF EXITS " + VIDEOS_TABLE_NAME + ";"); createTable(sqLiteDatabase); } there is a S missing in the SQL statements, it should be exiSts not exits ... b) In the Gdata returned by the webservice there is no XML Tag with the name *thumb_uri* ... I don't know, maybe the API did change or whatever, however, the check *private void verifyValues(ContentValues values)* does not work. Class FinchVideoContentProvider around line 316 if (!values.containsKey(FinchVideo.Videos.THUMB_URI_NAME)) { throw new IllegalArgumentException("Thumb uri not specified: " + values); } => will constantly fail because the thjumb_uri is missing I like the book in general, but I think it would become even better if you would describe this *master-conzept* called *Network MVC* first and then explain each of its components, instead of explaining the components first and besides of that given the readers the name of the concept they are actually implementing. But maybe I was also just too focused on that part ^^ Anyway good job! Cheers! Sebastian Wagner

Note from the Author or Editor:
Yep. It's a bug.

Sebastian Wagner  Apr 04, 2011 
PDF
Page 311

BaseColumns was treated as a class at two places in the following paragraph on page 311: The CONTENT_URI must be of type public static final Uri. It is defined in the Finch Video class of our simple video application. In our public API class we start by extending the class BaseColumns, and then define a string named AUTHORITY: public final class FinchVideo.SimpleVideos extends BaseColumns { public static final String SIMPLE_AUTHORITY = "com.oreilly.demo.pa.finchvideo.FinchVideo"; BaseColumns is a public interface (i.e., not a public class) and thus "implements" should be used instead of "extends".

Note from the Author or Editor:
COnfirmed. Note sent to submitter

Emerson Wang  Dec 26, 2011 
PDF
Page 316
1st paragraph

Java is case sensitive. URIMatcher used three times in the following 1st paragraph should be replaced with UriMatcher: The URIMatcher class supports mapping from URIs containing authority, path, and ID strings to application-defined constants usable with case statements that handle particular subtypes of URIs. From there, the provider can decide what SQL operations to use to manage actual table rows. A typical content provider will create a static instance of URIMatcher and populate it using a static initializer that calls URIMatcher.addURI to establish the first-level mapping used later in content provider data methods.

Note from the Author or Editor:
Confirmed

Emerson Wang  Dec 28, 2011 
PDF
Page 320
1st paragraph

DatabaseHeIper extends SQLiteOpenHelper and thus DatabaseHelper.onUpgrade method should be called instead of DatabaseHelper.onUpdate method in the following 1st paragraph: If this number is higher than the database version of the database itself, the application calls the DatabaseHelper.onUpdate method.

Note from the Author or Editor:
true.

Emerson Wang  Dec 28, 2011 
PDF
Page 321

Missing AUTOINCREMENT after INTEGER PRIMARY KEY in the following createTable method: private void createTable(SQLiteDatabase sqLiteDatabase) { String qs = "CREATE TABLE " + VIDEO_TABLE_NAME + " (" + FinchVideo.SimpleVideos._ID + " INTEGER PRIMARY KEY, " + FinchVideo.SimpleVideos.TITLE_NAME + " TEXT, " + FinchVideo.SimpleVideos.DESCRIPTION_NAME + " TEXT, " + FinchVideo.SimpleVideos.URI_NAME + " TEXT);"; sqLiteDatabase.execSQL(qs); }

Note from the Author or Editor:
he's right

Emerson Wang  Dec 29, 2011 
PDF
Page 325

"deletion" should be replaced with "update" in the following comment in the update method: public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { // the call to notify the uri after deletion is explicit getContext().getContentResolver().notifyChange(uri, null);

Note from the Author or Editor:
It would be a great idea, in general, to copy the working code into the text, again.

Emerson Wang  Dec 30, 2011 
PDF
Page 342

"FinchVideoProvider" used in the following statement should be replaced with "FinchVideoContentProvider": Now we’ll look into the behaviors that FinchVideoProvider inherits from RESTfulContentProvider in order to execute RESTful requests.

Note from the Author or Editor:
Text is incorrect

Emerson Wang  Jan 06, 2012 
Printed
Page 348
deleteOld method

deleteOld() tries to delete the old cached file like this: mFinchVideoProvider.deleteFile(ID); This is wrong because ID is the record ID from ID_COLUMN. You should get file name from MEDIA_ID_COLUMN and use that to delete file. String Media_ID = old.getString(FinchVideo.MEDIA_ID_COLUMN); mFinchVideoProvider.deleteFile(Media_ID); Great book! Thanks.

Note from the Author or Editor:
I sent mail to the reader, yes, this appears to be a bug. I'll fix for next version.

Anonymous  Nov 17, 2011 
PDF
Page 352

In the following method, "initialValues" in the last return statement should be replaced with "values": public Uri insert(Uri uri, ContentValues initialValues) { ...... ContentValues values; if (initialValues != null) { values = new ContentValues(initialValues); } else { values = new ContentValues(); } SQLiteDatabase db = getDatabase(); return insert(uri, initialValues, db); } i.e., the above return statement should be as follows: return insert(uri, values, db);

Note from the Author or Editor:
Code in the text is incorrect.

Emerson Wang  Jan 06, 2012 
Other Digital Version
1429
"A static declaration..."

Chapter "Final and Static Declarations": Throughout the chapter non-static members are called dynamic. Static does not imply dynamic nature of members, but rather membership: is it part of the instance or not. Dynamic implies that member is somehow changeable, which is misleading. Standard name for non-static members are instance members, so it is not about static vs. dynamic, it is about static vs. instance member.

Note from the Author or Editor:
Note sent to submitter

Željko Trogrlić  Jan 09, 2012