01-Errata/Corrections
satya - Tuesday, April 13, 2010 4:11:43 PM
Chapter 3, page 74, Listing 3-19
The code "Listing 3-19. Reading a Raw Resource" should instead be
Credit
Many thanks to Eduardo Berton for pointing out
String getStringFromRawFile(Activity activity)
throws IOException
{
Resources r = activity.getResources();
InputStream is = r.openRawResource(R.raw.test);
String myText = convertStreamToString(is);
is.close();
return myText;
}
String convertStreamToString(InputStream is)
throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i = is.read();
while (i != -1)
{
baos.write(i);
i = is.read();
}
return baos.toString();
}
satya - Tuesday, April 13, 2010 4:17:00 PM
Chapter 6, Page 221, Listing 6-3
The drawable resource names, like other resource names cannot have a "-" in them. Replace them with an underscore "_" instead
Credit
Michael Eager
The listing instead should read
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/colored_ball1" android:duration="50" />
<item android:drawable="@drawable/colored_ball2" android:duration="50" />
<item android:drawable="@drawable/colored_ball3" android:duration="50" />
<item android:drawable="@drawable/colored_ball4" android:duration="50" />
<item android:drawable="@drawable/colored_ball5" android:duration="50" />
<item android:drawable="@drawable/colored_ball6" android:duration="50" />
<item android:drawable="@drawable/colored_ball7" android:duration="50" />
<item android:drawable="@drawable/colored_ball8" android:duration="50" />
</animation-list>
satya - Wednesday, April 14, 2010 1:32:12 PM
Chapter 2, Page 53, Figure 2-15
onStop() should go to onRestart() instead of onRestart going to onStop().
Credits
Ninh Nguyen
We will post a correct diagram soon here.
satya - Thursday, April 15, 2010 9:26:09 AM
Chapter 6, Page 223, Listing 6-4
ImageView imgView = (ImageView)findViewById(R.id.imageView); should be ImageView imgView = (ImageView)findViewById(R.id.animationImage);
Credit
APress On line submitter
(Probably Michael Eager)
Thanks for pointing out.
This is caused by the discrepancy in the XML file and the java source code. You can adjust either. In the XML file the id was originally called "imageView" and there was a timing difference between when the code was copied from the source.
satya - Wednesday, April 28, 2010 11:16:54 PM
Chapter 13, Page 474, Listing 13-9
The code
public void onDeleted(Context context, int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
BDayWidgetModel.removePrefs(context, appWidgetIds[i]);
}
}
should read
public void onDeleted(Context context, int[] appWidgetIds)
{
final int N = appWidgetIds.length;
for (int i=0; i<N; i++)
{
BDayWidgetModel bwm =
BDayWidgetModel.retrieveModel(context, appWidgetIds[i]);
bwm.removePrefs(context);
}
}
Credit
Adam from kku.ac.kr
satya - Wednesday, May 12, 2010 10:10:39 PM
Chapter 2, Figure 2-11
This figure was smeared in production and we missed it. Here is what it should look like
satya - Wednesday, May 12, 2010 10:14:47 PM
Chapter 2, Figure 2-15
One of the arrows got reversed in production. we missed this as well. Here is what it should look like
satya - Saturday, August 07, 2010 1:41:17 PM
Chapter 3 Sample Projects (Corrections in code and more)
As we are revising chapters for ProAndroid3, I have seen slight inconsistencies in the code in Chapter 3. To correct this I have uploaded a sample project that you can download by refering to the ProAndroid 2 Downloads Page. The name of the sample project zip file is Ch03_TestProviders.zip. You should be able to download this zip file, unzip it and make a project in your eclipse environment. I regrest the delay in doing this and thank you very much for your patience.