 |
BOOK: Professional Android 4 Application Development
 | This is the forum to discuss the Wrox book Professional Android 4 Application Development
Reto Meier; ISBN: 978-1-1181-0227-5
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional Android 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 17th, 2013, 07:25 AM
|
|
Authorized User
|
|
Join Date: Feb 2013
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Chapter 7 - Earthquake example question
I'm on page 240 of the book following the earthquake example. When I go to the number 6 Update the onActivityResult Handler I don't understand why in the book there is a "Thread t" and in the code example there isn't one?
Why is the code in the book different than the code available for download?
At the end of this example the book refers to Chapter 7 Earthquake Part 2. I imported the example into Eclipse, and I don't see the same code. Why?
Thanks in advance
__________________
Marcelo Oliveira
MAOWebSolutions.com
|
|

July 24th, 2013, 08:58 AM
|
|
Authorized User
|
|
Join Date: Apr 2013
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I can't answer that, only Reto can. He has a profile on Google+. The book is correct, you have to invoke network requests on a separate thread. I can give an educated guess. I think that you can invoke network requests on the main thread if you do not specify a <uses-sdk> permission in the project's androidmanifest.xml file.
|
|
The Following User Says Thank You to Android23Geek For This Useful Post:
|
|
|

August 21st, 2013, 11:12 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hello,
Kind of similar to the above answer, quite possibly because from ICS networking has to be done on a separate thread (Gingerbread did not) the book was updated but the samples not.
In order to get it working without threads on ICS upwards without threads (but really only for testing purposes) you should add to the onCreate event:
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().buil d();StrictMode.setThreadPolicy(policy);
|
|
The Following User Says Thank You to neilw For This Useful Post:
|
|
|

September 4th, 2013, 09:07 AM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I've just been trying the code properly and for some reason Wrox, Reto and the entire Technical proof reading team have failed to test the download code.
Essentially, the download code for chapter 7 removes all the threading/handler code.
The only solution is to get the earlier code (or type it in) and take it from there.
My worry is every chapter from now one will also have the duff code.
Thanks for wasting an afternoon of my time Wrox.
|
|

September 4th, 2013, 01:20 PM
|
|
Authorized User
|
|
Join Date: Oct 2012
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I am the tech editor for the book and I understand your frustration. Though I don't think it's a matter of the downloaded code removing the threading/handling. The original draft of the book did not have the threading code and I requested that it be put in, which it was. Apparently the downloaded code is the original version, but it wasn't something I was given to review, so I didn't know there was a problem. I will check with Reto to see if he can provide the correct version.
As for the other code examples, I will assume they are also earlier code, so any network access should be done on a separate thread.
Sorry for the troubles.
|
|

September 4th, 2013, 02:14 PM
|
|
Registered User
|
|
Join Date: Aug 2013
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hello,
Thanks for the reply. But no, later chapters don't work either. Well it seems something has been done to address threading but not quite:
I'm doing chapter 8 and while the EarthQuakeListFragment has reinstated the threading (which I'm guessing means chapter 8 has been updated for the later version of android?) the code in the main activity Earthquake.java forgets to do this in the code returning back from preferences:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
........
earthquakeList.refreshEarthquakes();
}
It would be nice if you could update the errata to include a fix for the earthquake feed causing a null pointer exception due to the xml generating a 'deprecated feed' xml entity.
thanks.
|
|

September 4th, 2013, 02:40 PM
|
|
Authorized User
|
|
Join Date: Oct 2012
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've sent Reto a message about the code. What's available to download is something I'm not really in control over, just editing what is sent to me, so he will probably have to handle it.
If it's the downloaded code for later chapters that isn't working, then it's probably the same problem with earlier code than the book. I tried to make sure everything that was in the book copy was tested. But that doesn't mean I didn't overlook a snippet or that my edit made it in the final copy.
The earthquake feed is another thing Reto will probably have to address since it's his example. If I hear back from him on updating the code, I'll mention that as well since it will be a problem for anyone using the book at this point.
|
|

September 9th, 2013, 07:49 PM
|
|
Authorized User
|
|
Join Date: Feb 2013
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
We look forward to it...
We look forward to getting right code or any updates.
Thank you
__________________
Marcelo Oliveira
MAOWebSolutions.com
|
|
 |
|