Errata

Learning Android

Errata for Learning 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
1
United States

Not sure what page it's on, reading online. It's in ch 7, AsyncTask section. Errata for book says that this should be updateStatus, but when using the library found at github.com/learning-android/yambaclientlib the updateStatus method doesn't exist and Eclipse suggests using postStatus. I have yet to complete the project, so I don't know if postStatus is going to work, but there it is. Maybe an error in the errata?

Note from the Author or Editor:
Confirmed, fixed. It should be postStatus(), not updateStatus(). The API changed and missed one spot to update.

Russell Zauner  Jul 25, 2014  Sep 12, 2014
Printed
Page 117
Canada

Using 2nd edition of the book, most recent version of Eclipse as per June 2014. On p.112 and p.117 the YambaClientLib is discussed.

As indicated, I downloaded the yambaclientlib.jar file and performed a drap-and-drop into the libs folder. I then updated the StatusActivity.java file to import the two libs needed:

import com.marakana.android.yamba.clientlib.YambaClient;

import com.marakana.android.yamba.clientlib.YambaClientException;


Receive an "import cannot be resolved" error for both lines of code.

This process needs further clarification.

Note from the Author or Editor:
You may need to right-click on the JAR and add this jar to the build path. This changes from version to version.

Kevin S  Jun 08, 2014 
Printed
Page 28
5th paragraph, second sentence

Should generateList be printList?

Note from the Author or Editor:
Fixed.

Anonymous  May 14, 2014  Sep 12, 2014
Printed
Page 170
RefreshService Example

When I try out the getTimeline() example, I get the following error message:
"com.marakana.android.yamba.clientlib.YambaClientException: Unexpected error while communicating tohttp://yamba.marakana.com/api".

There seems to be a problem with the dateparser as stated in this error message:
"Caused by: java.text.ParseException: Unparseable date: "Mon Apr 21 10:58:47 -0700 2014" (at offset 0)"

Note from the Author or Editor:
This is a known problem when your client (Android device or emulator) is configured to use non-US locale.

Thomas Helmke  Apr 21, 2014 
PDF
Page 227
Sentence preceding the "Broadcasting Intents" title

Typo: "sevice" instead of "service"

Note from the Author or Editor:
Confirmed, and fixed

Francesco Benacci  Apr 21, 2014  Sep 12, 2014
Printed
Page 154
Section title at top of page

The text of the title should say,

Updating MainActivity to Handle Menu Events

Note from the Author or Editor:
Corrected! Thanks!

Grant Robertson  Apr 06, 2014  Sep 12, 2014
Printed
Page 112
Entire section under Adding the Twitter API Library

You really need to explain better how to get the actual .jar file from the GIT repository. Having never used GIT, it took quite a lot of digging around to find the actual .jar file instead of the source in various formats.

From the repository home page, you have to click on the bin folder, then click on the link that LOOKS like it is the .jar file, but isn't. And then you have to click the RAW button. Yeah, incredibly intuitive. You state over and over again that the link to the .jar file is: https://github.com/learning-android/yambaclientlib/ but that is not complete. The actuall, FULL, path to the .jar file is:

https://github.com/learning-android/yambaclientlib/raw/master/bin/yambaclientlib.jar

Grant Robertson  Apr 06, 2014  Sep 12, 2014
PDF
Page 169
Code

case R.id.action_refresh:
startService(new Intent(this, RefreshService.class)); //
break;

should be:

case R.id.action_refresh:
startService(new Intent(this, RefreshService.class)); //
return true;

Otherwise it won't compile

Note from the Author or Editor:
True - thanks for noticing this one. Fixed!

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 168
Last paragraph

The sentence:

"To handle new menu items, we need to update the onOptionsItemSelected() method
in StatusActivity, just as we did in �Updating StatusActivity to Handle Menu
Events� on page 154."

should be:

"To handle new menu items, we need to update the onOptionsItemSelected() method
in MainActivity, just as we did in �Updating StatusActivity to Handle Menu
Events� on page 154."

Also, the title of page 154 is probably wrong, should be MainActivity there as well

Note from the Author or Editor:
Fixed.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 168
res/menu/main.xml code

The code illustrated here is completely unrelated from how it was introduced earlier, and also from how it is used in the following page.

It should be:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings" />

<item
android:id="@+id/action_tweet"
android:icon="@android:drawable/ic_menu_add"
android:showAsAction="always|withText"
android:title="@string/tweet" />

<item
android:id="@+id/action_refresh"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="always"
android:title="@string/refresh" />

<item
android:id="@+id/action_purge"
android:icon="@android:drawable/ic_menu_delete"
android:title="@string/purge" />

</menu>

Note from the Author or Editor:
Confirmed

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 156
Figure 9-3

The SettingsActivity, at this point, contains only the username and password sections. Maybe the Refresh Interval will be added later?

Note from the Author or Editor:
Yes, this screenshot if some slightly different version of the app.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 153
3rd paragraph in the "Loading the Menu" section

The sentence:

"You need to update the StatusActivity to load the options menu. To do that, add an
onCreateOptionsMenu() method to StatusActivity."

should be:

"You need to update the MainActivity to load the options menu. To do that, add an
onCreateOptionsMenu() method to MainActivity."

Note from the Author or Editor:
Confirmed and fixed.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 144
First paragraph after the code

The sentence:

"It has three children, all of the EditTextPreference type."

should be:

"It has two children, all of the EditTextPreference type."

Note from the Author or Editor:
Confirmed - fixed.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 129
Code

The code for StatusActivity.java in this page is different from the one at pages 121-122-123, which was almost correct.
For example, the textCount EditText will never turn yellow, as it should be instead.
This wrong code is reprised at page 133.

Note from the Author or Editor:
Confirmed and fixed.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 122
Code

The code:

if (count < 10)
textCount.setTextColor(Color.YELLOW);
else if (count < 0)
textCount.setTextColor(Color.RED);
else
textCount.setTextColor(defaultTextColor);

should be:

if (count < 0)
textCount.setTextColor(Color.RED);
else if(count < 10)
textCount.setTextColor(Color.YELLOW);
else
textCount.setTextColor(defaultTextColor);

otherwise the text will never turn red

Note from the Author or Editor:
Correct - fixed!

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
PDF
Page 117
Code

yambaCloud.updateStatus( params[0] );

should be:

yambaCloud.postStatus( params[0] );

Looking at the source code for yambaclientlib, it is confirmed that no updateStatus method is present for class YambaClient.

It has been corrected later in the book, though (e.g. page 122).

Note from the Author or Editor:
Fixed. You're correct.

Francesco Benacci  Apr 05, 2014  Sep 12, 2014
Printed
Page 19
Last function of example 2-12

the last function returns a variable named "value", but no such variable is defined, resulting in a compile error. This is probably supposed to be:

public String toString() {
return Integer.toString(number);
}

Note from the Author or Editor:
To be fixed in the next update

Joshua Davies  Mar 14, 2014  Mar 21, 2014
Printed
Page 24
Example 2-18

The file name given is MsgTypeOneExtended.java
Shouldn't it be MsgTypeImplementationExtended.java (the same as in the class statement)?

Note from the Author or Editor:
To be fixed in update

Johs. Lind  Mar 05, 2014  Mar 21, 2014
Printed
Page 12
Figure 2-1

The picture lets us believe that only the folders com and examples will be created. The marakana folder should be there too.

Note from the Author or Editor:
Image update in next update

Johs. Lind  Mar 05, 2014  Mar 21, 2014
Printed, PDF
Page xiiii
Using Code Examples Section

The download link points to the files for the first edition.

This sentence:

Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/marakana/LearningAndroidYamba.

Should say:

Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/learning-android

O'Reilly Media
 
Feb 21, 2014  Mar 21, 2014
Printed
Page 109 - Package Name

The package name in the text is "com.marakana.android.yamba" but in the Figure 7-6 is "com.marakana.yamba"

Note from the Author or Editor:
Image update in update

Dante  Feb 16, 2014  Mar 21, 2014
PDF
Page 254
Example 16-3

YambaApplication class and its getYambaClient() method has not been created yet.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 12, 2014  Sep 12, 2014
PDF
Page 172
comment #4 for the code

"We call getYambaClient() in YambaApplication to get the yamba object," should be removed.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 249
Example 15-16

- "i" after "urlConnection.setFixedLengthStreamingMode(data.getBytes().length());" should be removed.
- boundary should be defined like "String boundary = "*****";"
- extra quotation mark(") after "boundary" in 'urlConnection.setRequestProperty("Content-Type",
"multipart/form-data;boundary=" + boundary");' should be removed.

Note from the Author or Editor:
Book is updated with the corrections

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 249
Example 15-15

"i" after "urlConnection.setFixedLengthStreamingMode(data.getBytes().length());" should be removed.

Note from the Author or Editor:
updated in book

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 246
Example 15-10

Closing quotation mark(") is missing for getURL.

Note from the Author or Editor:
updated in book

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 238
Example 14-3

Inconsistent with the explanation below this code.
android:initialLayout and android:label should be specified.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 12, 2014  Sep 12, 2014
PDF
Page 225
2nd line of the section "Testing the Boot Receiver"

"either" should be removed.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 218
Example 12-11

This master-detail view has an architectural bug.
Details Fragment tries to fetch tweet id via Intent passed to its hosting Activity in onResume(). But in landscape orientation, the hosting activity, Main Activity, is not passed tweet id, and then the detail view gets cleared.
I suggest the following modification:
- Do not create Details Activity. Make Main Activity host both fragments and switch fragments in portrait orientation.
- Pass a tweet id using "Fragment Arguments" scheme convention.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 12, 2014  Mar 21, 2014
PDF
Page 216
Figure 12-2

Lower-right activity's name should be "Details Activity."

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 213
comment #2 for the code

"Also notice that it is static final, meaning that it?s a constant." should be deleted.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 218
commnet #2 for Example 12-10

It is also important to set 0dp to android:layout_width of both elements.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 213
comment #6 for the code

"Using the same Android helper method we used in our previous example, DateUtils.getRelativeTimeSpanString()," is supposed to be "Using the Android helper method DateUtils.getRelativeTimeSpanString()," because it is the first time to use getRelativeTimeSpanString().

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 213
comment #1 for the code

"VIEW_BINDER is defined later in our code." should be deleted.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 192
Example 11-8

The code is inconsistent with the explanation above the code saying "This may or may not contain an ID. If it does, the ID indicates the specific record
that needs to be updated, and we can ignore the selection." and "The selection and its arguments are omitted when there is an ID."

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 190
Example 11-6

Example 11-6 does not show the implementation of getId().

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 189
last line

"or vnd.marakana.yamba.mstatus" should be deleted.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 169
comment #1 for the code

"Then onStartCommand() is
called, regardless of whether this service is new or already running" is mentioning normal Service not Intent Service.

Note from the Author or Editor:
The book will be updated to fix the error.The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 161
1st paragraph

There is not API root in the XML file.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 11, 2014  Mar 21, 2014
PDF
Page 154
Example 9-8

In onOptionsItemSelected, if you don't handle the menu item, you should call the superclass implementation of onOptionsItemSelected(), even though it returns false in this example and ends up the same result.
So, "return false;" for 'default' option should be replaced with "return super.onOptionsItemSelected(item);".

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 157
2nd paragraph

Since this code is check that username and password are not empty before it attempts to log in, this code will NOT "attempt to log in with an empty username and password, and thus fail."

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 157
1st paragraph

In fragments, pass getActivity() instead of "this" to PreferenceManager.getDefaultSharedPreferences() as in Example 9-9.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 155
paragraph just before Shared Preferences and ... section

StatusActivity is supposed to be MainActivity.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 154
Example 9-8

After I read comments from Tim and Francesco Benacci, I guess the option for R.id.action_tweet should be removed from the switch statement for now.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 149
unnamed figure

The project name is supposed to be "Yamba"

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
ePub
Page 150
Part 4: Content Providers -> The dbHelper class

... Android rovides a class with the common ...
This should read
... Android provides a class with the common ...

Note from the Author or Editor:
The book will be updated to fix the error.

maxolasersquad  Feb 10, 2014  Mar 21, 2014
PDF
Page 120
Example 7-7

I think it would be better to remove "+" in
android:layout_alignLeft="@+id/editStatus"
android:layout_alignTop="@+id/buttonTweet"

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 119
2nd paragraph

"Update Status" is supposed to be "Tweet."

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 113
2nd paragraph

in "choose the rightmost tab at the bottom that says_AndroidManifest.xml_", AndroidManifest.xml is wrapped with extra underscores(_).

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 109
Figure 7-13

Figure 7-13 is NOT a LogCat View.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 10, 2014  Mar 21, 2014
PDF
Page 102
layout_weight

There are many mistakes:
(1) layout_weight can have 0 or any positive number. If you want to split the remaining space 2-1 for 2 elements, set their layout_weight 2 and 1 respectively, not 0.666666667 and 0.333333333.
(2) It implies the weight of 'remaining' space not whole available space.
(3) fill_parent is deprecated. Use match_parent instead.
(4) Only when the "first" element in LinearLayout has match_parent for its layout_width or layout_height depending on the LinearLayout's orientation, it hogs all the space and pushes out other elements "regardless of the value of layout_weight."

I'm wondering authors seem not understanding this kind of basic concept.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 07, 2014  Mar 21, 2014
PDF
Page 101
Example 7-1

Actually it's not mistake.
Although ADT inserts '+' before every id, it should be deleted when it used in android:layout_below or likes.

CamelHarry  Feb 07, 2014  Mar 21, 2014
PDF
Page 251
1st paragraph of Networking in the Background using AsyncTask...

In "it cannot be done in the the UI thread", "the" is duplicated.

Note from the Author or Editor:
The book will be updated to fix the error.

CamelHarry  Feb 07, 2014  Mar 21, 2014
PDF
Page 80
Last paragraph

In "To help understand the diagrams as we keep moving through the the design", "the" is duplicated.

Note from the Author or Editor:
To be fixed in update

CamelHarry  Feb 07, 2014  Mar 21, 2014
PDF
Page 59
1st line

resources.ap is supposed to be resources.ap_.

Note from the Author or Editor:
To be fixed in update

CamelHarry  Feb 06, 2014  Mar 21, 2014
PDF
Page 231
Summary paragraph

The notification in NotificationReceiver will not fire unless you add a receiver to the AndroidManifest.xml as follows:

<receiver android:name=".NotificationReceiver" >
<intent-filter>
<action android:name="com.marakana.android.yamba.action.NEW_STATUSES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 03, 2014  Mar 21, 2014
PDF
Page 40
Last paragraph of Resources

resources.ap\_ is supposed to be resources.ap_.

Note from the Author or Editor:
To be fixed in update

CamelHarry  Feb 03, 2014  Mar 21, 2014
PDF
Page 38
1st paragraph (above the Figure 3-2)

"in" in the "between standard Java (on the left) in Android
using Dalvik (on the right)" may be "and".

* I'm not a native English speaker, so I may be wrong.

Note from the Author or Editor:
To be fixed in update

CamelHarry  Feb 03, 2014  Mar 21, 2014
PDF
Page 221
Figure 12-3

Your app will not look like the image as you do not have the "FreshnessView" View (see errata for p218). It will look similar, just without the green bar.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 03, 2014  Sep 12, 2014
PDF
Page 218
Example 12-11

The code in this example is meant to be a continuation for TimelineFragment, however, this code has issues and will not compile successfully in the supplied form:

* The "list_item" layout does not include a View for the "list_item_freshness" reference (same comment as for the errata on p206/208).
* whilst there is now a case statement for "list_item_freshness" (in the "setViewValue" method) even though it doesn't exist in the "list_item" layout, the code in it references a previously unknown View called "FreshnessView". This appears to be a custom control, but as the required class is not supplied or introduced, it will give a compiler error.

Therefore, to get it to compile:

* Remove the last entry from the "FROM" array
* Remove the last entry from the "TO" array
* Comment out the entire "case R.id.list_item_freshness" case statement

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 03, 2014  Mar 21, 2014
PDF
Example 12-11

The code in this example is meant to be a continuation for TimelineFragment, however, this code has issues and will not compile successfully in the supplied form:

* The "list_item" layout does not include a View for the "list_item_freshness" reference (same comment as for the errata on p206/208).
* whilst there is now a case statement for "list_item_freshness" (in the "setViewValue" method) even though it doesn't exist in the "list_item" layout, the code in it references a previously unknown View called "FreshnessView". This appears to be a custom control, but as the required class is not supplied or introduced, it will give a compiler error.

Therefore, to get it to compile:

* Remove the last entry from the "FROM" array
* Remove the last entry from the "TO" array
* Comment out the entire "case R.id.list_item_freshness" case statement

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 03, 2014  Mar 21, 2014
PDF
Page 20
In the Method showErrorHandling()

The purpose of example 2-12 ist to show how error handling works.
In this example a class named SimpleExampleWErrorHandling is created. But within there is a confusion between this class and the previous example 2-4. Within the method showErrorHandling() an object of the class SimpleExample is created, then the method setValueWithException() is called on this object, but this method is only defined in SimpleExampleWErrorHandling.
The related text deepens the confusion as paragraph 2 on p.21 talks about the method setValue() which should throw exceptions (it should probably read setValueWithException).

This example seems to be a rather bad case of sloppy copy and paste.

This error in combination with the large number of unconfirmed errata in the 2ND EDITION bodes ill for the overall quality of this book.

Note from the Author or Editor:
The book will be updated to fix the error.

David Pr�m  Feb 02, 2014  Sep 12, 2014
PDF
Page 212
Example 12-7

The code in this example is meant to be a continuation for TimelineFragment, however, it has major breaking differences to the previous iteration and will not compile without errors. For example, in the "onActivityCreated" method:

* setEmptyText("Loading data...")
>> not present in previous iteration.
* adapter = new SimpleCursorAdapter(getActivity(), R.layout.row, null, FROM, TO, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
>> "adapter" is not declared, should be mAdapter. There is no layout called "row" and there is no need to have "FLAG_REGISTER_CONTENT_OBSERVER" as an additional flag.
* adapter.setViewBinder(new TimelineViewBinder());
>> "adapter" is not declared, should be mAdapter.
* setListAdapter(adapter);
>> "adapter" is not declared, should be mAdapter.
* getLoaderManager().initLoader(0, null, this);
>> should be: getLoaderManager().initLoader(LOADER_ID, null, this);

In the "setViewValue" method:

* "R.id.text_created_at" does not exist, probably should be "R.id.list_item_text_created_at".

Make all of these changes and the code compiles and works.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 211
We can now run the app...

As a follow-up to the previous comment, to get the app to run, comment out the line:

mAdapter.setViewBinder(VIEW_BINDER);

and your code will run.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 211
We can now run the app...

You will *not* be able to run the app at this point because VIEW_BINDER is not defined in your class "TimelineFragment" up until this point and as such you will encounter a compiler error. VIEW_BINDER is defined on page 219(!)

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 210
Example 12-6

MainActivity is already set as the main entry point (done on page 150), so it is unclear why this is repeated here.

Also, suddenly without any explanation, the StatusActivity activity gained an intent versus previous versions of the AndroidManifest file - however, if you are following the code this will finally allow it to work without crashing when you select the "action_tweet" command from the ActionBar.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 208
Example 12-5

The statement:

private static final int[] TO = { R.id.list_item_text_user, R.id.list_item_text_message, R.id.list_item_text_created_at, R.id.list_item_freshness };

will cause a compiler error as the "list_item" layout does not include a View for the "list_item_freshness" reference (code is shown in Example 12-3 (p205).

Therefore, to solve, change the code so that you have:

private static final String[] FROM = { StatusContract.Column.USER,StatusContract.Column.MESSAGE, StatusContract.Column.CREATED_AT};
private static final int[] TO = { R.id.list_item_text_user,R.id.list_item_text_message, R.id.list_item_text_created_at};

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 206
Example 12-4

The "list_item" layout does not include a View for the "list_item_freshness" reference in Example 12-3 (p205), only the references for "list_item_text_user", "list_item_text_message" and "list_item_text_created_at" are present in the "list_item" layout.

Therefore, you will experience compile errors if you try to compile at this point.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 203 - 204
Example 12-1

The statement:

case R.id.action_tweet:
startActivity(new Intent("com.marakana.android.yamba.action.tweet"));

will cause the application to crash as at this point in the book, there is no entry in AndroidManifest.xml for the intent for StatusActivity (this is not shown until page 210).

Furthermore, the statement:

case R.id.action_purge:
int rows = getContentResolver().delete(StatusContract.CONTENT_URI, null, null);
Toast.makeText(this, "Deleted "+rows+" rows",
Toast.LENGTH_LONG).show();
return true;

suddenly appears without any explanation.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 168 - 169
Update the Options Menu Handling section

This tells you to update "StatusActivity.java" for the method "onOptionsItemSelected()" even though on page 154 you actually added it to "MainActivity.java" - which is where it should be changed. However, the code shown in this second still does not match what was shown on page 154 in any case. This can be verified in that the line "startActivity(new Intent(this, PrefsActivity.class));" is nowhere else in the text.

If you are following this example, just keep on with your existing code in MainActivity.java and add the new case statement for "itemRefresh".

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 168
Add Menu Items section / Example 10-3

The "Menu.xml" referenced is inconsistent with the previously defined menu, "main.xml", furthermore, the code provided in Example 10-3 does not match that given for the original "main.xml" defined earlier in the book.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 02, 2014  Mar 21, 2014
PDF
Page 154
Example 9-8 - onOptionsItemSelected, case R.id.action_tweet

Whilst it is clear what is happening for the "action_settings" case by calling a new intent and passing the SettingsActivity class, it is not so clear what is happening for the "action_tweet" case.

In fact, whilst this code compiles, your app will crash if you try to "add new tweet" via the Action Bar menu you just created.

Reason for this is that the intent hasn't been set up for StatusActivity in AndroidManifest.xml - this is not shown until chapter 12!

If you want to get your app to work at this point, a quick fix is to replace the following line:

case R.id.action_tweet:
startActivity(new Intent("com.marakana.android.yamba.action.tweet"));

with this:

case R.id.action_tweet:
startActivity(new Intent(this, StatusActivity.class));

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 151
The caption of Figure 9-3

This should read:

Figure 9-3. *Main.xml" in developer-friendly view

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 148
Point 2. of the list at the bottom

This should read

2. Add onCreateOptionsMenu() to the activity that should have this menu. This is where we inflate the *main.xml* resource.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 146
Example 9-3

As the SettingsFragment implements OnSharedPreferenceChangeListener then the class should also include:

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
}

However, this is not shown in Example 9-3.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Sep 12, 2014
PDF
Page 144
Figure 9-2 / Example 9-1

In the figure, the entries do not correspond to the code given in Example 9-1, such that:

* The apiRoot EditTextPreference is missing from Example 9-1 (or is included by mistake in Figure 9-2).
* The "Title" and "Summary" string resource entries in Figure 9-2 do not match. For example, "@string/titleUsername" versus "@string/username".

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 143
Figure 9-1

In the figure, the "File" field ("prefs.xml") does not match the file you are told to create ("settings.xml").

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 129
United Kingdom

Chapter 8 needs a bit of a re-write as it is very unclear what you need to do - it's not obvious why you are performing some of the steps. To sum up, this is what you need to do:

* Rename "activity_status.xml" to "fragment_status.xml"
* Create a new class "StatusFragment" using the code from Example 8-3 (it's not clearly mentioned how this should be created, by copying existing code, or renaming a file).
* Create a new layout file "new_activity_status.xml" using the code from Example 8-5.
* Change your code in the "StatusActivity" using code from Example 8-4.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Mar 21, 2014
PDF
Page 124
Figure 7-19

The figure matches the first half of point 8 of page 123 - not sure this is correct since the text of point 8 of 123 contradicts itself, and as such should possibly be changed to show a figure with yellow text given the second half of point 8 of page 123. Please refer to the errata for page 123 as this is directly linked.

Note from the Author or Editor:
The book will be updated to fix the error.

Tim  Feb 01, 2014  Sep 12, 2014
PDF
Page 112
After "Adding the Twitter API Library"

There is no link mentioned for the "YambaClientLib" library, except in the preface, which points to https://github.com/marakana/LearningAndroidYamba which appears to be incorrect (or at least makes it very hard to find the correct file). I actually found a newer version at https://github.com/twitter-university/YambaClientLib however I am unsure if this is correct version.

Note from the Author or Editor:
The book will be updated to fix the error.
Correct repo is https://github.com/learning-android/yambaclientlib

Tim  Jan 31, 2014  Mar 21, 2014
PDF
Page 122
top

the code to color the text is wrong, should be:
textCount.setTextColor(Color.GREEN);
if (count < 0)
textCount.setTextColor(Color.RED);
else if (count < 10)
textCount.setTextColor(Color.YELLOW);

Note from the Author or Editor:
The book will be updated to fix the error.

Ronny De Winter  Jan 31, 2014  Mar 21, 2014
PDF
Page 28
Section "Generics"

"MsgTypeOne, MsgTypeTwo, and MsgTypeThree" are supposed to be MsgTypeImplementation, MsgTypeAdditional, and MsgTypeImplemen
tationExtended, respectively.

Note from the Author or Editor:
The book is updated with this corrected

CamelHarry  Jan 31, 2014  Mar 21, 2014
PDF
Page 27
3rd paragraph

In "we see if the MsgInterface in question is a
MsgTypeImplementationExtended class ((MsgTypeImplementationExtended) msg)", the quoted code is supposed to be if(msg.getMsgType().equals("MsgTypeImplementationExtended")).

Note from the Author or Editor:
The book is updated with this corrected

CamelHarry  Jan 31, 2014  Mar 21, 2014
PDF
Page 24
Title of Example 2-18

File name is supposed to be MsgTypeImplementationExtended.java.

Note from the Author or Editor:
The book is updated with this corrected

CamelHarry  Jan 31, 2014  Mar 21, 2014
PDF
Page 21
2nd paragraph

the logic explicitly
instantiates an Exception object and then ?throws? it (throw new Exception(""set
Value Exception- Value that is set is Negative!"")).

quotation mark(") is duplicated.

Note from the Author or Editor:
To be fixed in update

CamelHarry  Jan 31, 2014  Mar 21, 2014
PDF
Page 171
code

In the yambaclientlib.jar i managed to download from github (which is not at the address given in the book) two things are missing, relative to this code:

1) there is no YambaClient.Status. Here i can deal with having to use YambaClient.TimelineStatus.

2) there is no getTimeline method. The only similar one is fetchFriendsTimeline, but it's not documented.

Note from the Author or Editor:
The book will be updated to fix the error.
The correct location for this JAR is at https://github.com/learning-android/yambaclientlib

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 169
onOptionsItemSelected method

I'm sorry, i still believe this book is one of the best for Android development, but this chapter seriously needs to be fixed.

This paragraph is inconsistent with the previous one, which, in turn, was inconsistent with the previous contents of the books. It is apparent that the code has been taken from different iterations of the class.

The code on page 168 creates two items:
1) itemPrefs
2) itemServiceStart

The code on page 169, handles the selection of the items:
1) itemRefresh
2) itemPrefs

Now, it's clear that itemServiceStart == itemRefresh, but still...

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 168
Paragraph "Add Menu Items"

This paragraph is not consistent with the previous contents of the book:

1) There is no menu.xml file in the project at this point. I guess the file referred is status.xml, since the following code refers to StatusActivity.

2) The supposed contents of menu.xml were never seen before in the book. Indeed, just searching for ic_menu_preferences gives only a result, but not were expected. But... the bullet note number 1 says "This is the item we defined in the previous chapter.". Nope, we didn't.

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 141
4th paragraph

The sentence "So our interface will have three fields where the user can enter and edit his username, his password, and the API root". is not correct.

The API root is hardcoded in the jar, and indeed its corresponding field is not created in the code.

This same kind of problem impacts also page 144 (1st and last paragraph, where it says there are 3 children of PreferenceScreen, while instead there are only two).

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 155
1st paragraph

The sentence "At this point, we have only one menu item, but that
might change in the future." is partially not correct, since at this point we actually have two menu items.

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 145
Last paragraph before the code

I think the sentence "The SettingsFragment class extends the SettingsActivity class, an Android framework class that knows how to handle preferences."

should instead be (the following code proves that):

"The SettingsFragment class extends the PreferenceFragment class, an Android framework class that knows how to handle preferences."

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 145
2nd paragraph after "SettingsActivity" title

This errata "overrides" my previous one on the same page (while keeping reading i figured out what the actual mistake was).

The sentence "This will create a SettingsActivity.java file under your package in your source folder. Then do the same thing and create a SettingsActivity class."

should instead be:

"This will create a SettingsActivity.java file under your package in your source folder. Then do the same thing and create a SettingsFragment class."

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 145
2nd paragraph after "SettingsActivity" title

The sentence "This will create a SettingsActivity.java file under your package in your source folder. Then do the same thing and create a SettingsActivity class." is misleading.

When the file SettingsActivity.java is created, it already contains the SettingsActivity class.

A better wording could be:
"This will create a SettingsActivity.java file under your package in your source folder, containing the SettingsActivity class."

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 26, 2014  Mar 21, 2014
PDF
Page 123
Last paragraph

The paragraph has two mistakes.

It says "we?re using android.graphics.Color and not java.awt.Color", but few words before this sentence, it said "we start with the defaultTextColor, and switch to java.awt.Color.RED": it should be android.graphics.Color. The code is correct and doesn't rely on the java.awt.Color package.

The desired behavior is not clear: at first it says the text should turn red when the user has fewer than 10 character left. But later it says "So, if more than 10 characters are available, we are still
in the green. Fewer than 10 means we are approaching the limit, thus the counter
turns yellow. If we are past the limit of 140 characters, the counter turns red.".
The code implements the first approach: text never turns green or yellow.

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 123
Next to bullet number 2

The sentence "Because we don?t now what theme" should be "Because we don?t know what theme".

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 117
doInBackground method

Using the jar found at https://github.com/twitter-university/yamba/tree/master/libs, there is no postStatus method available for the yambaCloud variable. Instead, it seems the correct one is updateStatus

So the code:
yambaCloud.postStatus(params[0]);
should be instead:
yambaCloud.updateStatus(params[0]);

Note from the Author or Editor:
The book will be updated to fix the error.
The correct repo for 2nd edition is: https://github.com/learning-android

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 112
2nd paragraph after the "Adding the Twitter API Library" title

The link provided for YambaClientLib isn't correct. I found several repos in github that might point to the correct jar file.

I chose the most recent one, included in the repo at https://github.com/twitter-university/yamba, but still it left me with the doubt about having chosen the right file or not.

Note from the Author or Editor:
The book will be updated to fix the error.
The correct repo for 2nd edition is: https://github.com/learning-android

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 112
3rd paragraph after the "Adding the Twitter API Library" title

The sentence "making it easy for you to peek at its
source code and see the its inner workings" should be "making it easy for you to peek at its
source code and see its inner workings"

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 102
Final paragraph

A TextView named Title is mentioned, but it hasn't been added in the UI.

Note from the Author or Editor:
The book will be updated to fix the error.

Francesco Benacci  Jan 25, 2014  Mar 21, 2014
PDF
Page 83
The dbHelper class

"rovides" should be "provides".

Note from the Author or Editor:
To be fixed in the update

Davor Lozic  Jan 21, 2014  Mar 21, 2014
PDF
Page 60
At the start of the page (inside general note).

"th Emulator supports GPU..." => typo with the word "th" => "the".

Note from the Author or Editor:
To be fixed in update

Davor Lozic  Jan 20, 2014  Mar 21, 2014