Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 4th, 2016, 09:44 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Chapter 6 Earthquake Viewer

I have entered all the code for the Chapter 6 Earthquake Viewer app only to discover the http://earthquake.usgs.gov/eqcenter/.../1day-M2.5.xml for the string resource value is no longer valid. I've looked at the posts in this forum and another link was listed, but it no longer works either. Has anyone completed this app lately who has found the right URL for the string resource? This is a class assignment and it is due Sunday.
Reply With Quote
  #2 (permalink)  
Old March 5th, 2016, 06:23 AM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 6 Earthquake Viewer

Hi, yes things have changed ...
look at http://earthquake.usgs.gov/earthquak...v1.0/index.php
Look at atom syndication.
In stead of that 1 day M2.5.xml use http://earthquake.usgs.gov/earthquak...y/2.5_day.atom
for instance.
The use of the atom files is preferrable rather than the quakeml's, as they contain the entry and title tags and more that are expected in the chapter 6 example.
Reply With Quote
  #3 (permalink)  
Old March 5th, 2016, 09:02 AM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 6 not working

I tried that and it still didn't work. I even tried it using the source code in case I typed it in wrong from the book.
Reply With Quote
  #4 (permalink)  
Old March 5th, 2016, 09:29 AM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 6 not working

Try to debug into refreshEarthquakes, if you arrive in the for loop after
NodeList nl = docEle .... Then you can step through.
Such i did some years ago after not seeing any list, and it helped. Well, there is always a reason why it doesnt work
Reply With Quote
  #5 (permalink)  
Old March 5th, 2016, 10:05 AM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 6 not working

Hi Stephanie,
I remember a problem with the code of chapter 6 (no list at all)

In 2013 i found this exception in logcat :

"android.view.ViewRoot$CalledFromWrongThreadEx cept ion: Only the original thread that created a view hierarchy can touch its views"
If so, then it is likely due to calling aa.notifyDataSetChanged() in earthquakeListfragment.java from the thread that started refreshEarthquakes().
So the code in the book with the thread does not (always) work!!

You could try the chapter 9 example, where EarthquakeUpdateService is used.
Good luck!
Reply With Quote
  #6 (permalink)  
Old March 5th, 2016, 05:45 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Works in Android Studio, sort of...

I imported my Eclipse project into Android Studio just to see what happens and, surprise, I got a list of Earthquakes. However, I get 00:00 for all the times. I am not familiar with Android Studio since in class we are using Eclipse Luna, so I have no idea how to fix the time issue. I still can't get the program to list the data in Eclipse.
Reply With Quote
  #7 (permalink)  
Old March 5th, 2016, 06:24 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date parsing exception

Okay, I went back through the forum threads and found a fix for the time issue, but now I see I am getting a date parsing exception. The zeros for the time distracted me from the fact I have no dates either.
Reply With Quote
  #8 (permalink)  
Old March 6th, 2016, 05:55 AM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Date parsing exception

It surprises me that Android Studio does not raise that wrongthreadexception, i didnt try to run the same in studio.

Okay, i know what could cause the parsing error (if you didnt change the string in the line with simpledateformat).
Because the date string in the feed files now is for instance :
"2015-12-19T11:31:38.991Z",
so for all entries "yyyy-MM-dd'T'hh:mm:ss'.'SSS'Z'"
If you change that in the code :
SimpleDateFormat sdf =
new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'.'SSS'Z'",
Locale.getDefault());

Hope this helps to read the dates!
Reply With Quote
  #9 (permalink)  
Old March 6th, 2016, 02:16 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date issue resolved

Actually, after I thought about it a little more, I went back and looked a little closer and found a typo in the date format. After I fixed that and ran the debugger again, I could see the dates listed each time the program went through the loop, but they still weren't showing on the device. So I thought, maybe they aren't showing up because I wasn't asking them to. I took a look at my Quake.java and, sure enough, I had entered the book code and all it asks for is the time.

In Quake.java the book only lists:

sdf = new SimpleDateFormat("hh:mm");

So you only get the hour and minute values. I changed the code to:

Public String toString() {

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd, hh:mm");

String dateString = sdf.format(date);

return dateString + ": " + "M " + magnitude + ", " + details;

}

Now I have the date as well as the time in my listing.

I still can't get the program to give me the listing in Eclipse.
Reply With Quote
  #10 (permalink)  
Old March 6th, 2016, 04:07 PM
Registered User
Points: 22, Level: 1
Points: 22, Level: 1 Points: 22, Level: 1 Points: 22, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2016
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Eclipse debugger results

In Eclipse, when I run it through the debugger, I am not getting past checking to see if the http connection is okay. I'm getting a file not found error.

if(response code == HttpURLConnection.HTTP_OK) {

I get name: responseCode, value: 404

It's driving me nuts that the same URL working in Android Studio, but won't work in Eclipse.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Earthquake Chapter 6 newbie123 BOOK: Professional Android 4 Application Development 7 January 21st, 2013 06:09 AM
Chapter 7 Earthquake 2, Earthquake.java, error onActivityResult dbomberg BOOK: Professional Android 2 Application Development 2 November 30th, 2012 04:52 AM
Chapter 7 Earthquake viewer - Double Entries SmacArt BOOK: Professional Android 4 Application Development 0 October 31st, 2012 01:12 AM
Problem with earthquake viewer takhisis1 BOOK: Professional Android 2 Application Development 1 June 25th, 2012 09:41 AM
Please help: Chapter 9 Earthquake 4 dahe BOOK: Professional Android 2 Application Development 0 July 21st, 2010 03:41 PM



All times are GMT -4. The time now is 05:38 PM.


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