| Author |
Message |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Tue Nov 18, 2008 3:49 pm Post subject: |
|
|
| Something is wrong with your layout xml, SingleWheatherInfoView can't be found. That's what you callstack says.
|
|
| Back to top |
|
 |
|
|
 |
jeffy2010 Freshman

Joined: 18 Nov 2008 Posts: 5
|
Posted: Tue Nov 18, 2008 4:00 pm Post subject: |
|
|
Yes MrSnowflake..
When I open my main.xml on the layout view, it says the following
NoSuchMethodException:org.anddev.android.weatherforecast.views.SingleWeatherInfoView.<init>(android.content.Context, android.util.AttributeSet)
|
|
| Back to top |
|
 |
jeffy2010 Freshman

Joined: 18 Nov 2008 Posts: 5
|
Posted: Tue Nov 18, 2008 4:14 pm Post subject: |
|
|
Hi MrSnowflake.
I have resolved the issue and the app is running fine now.
The super of SingleWeatherInfoView which was extending the LinearLayout class had a parameter of "Map", which is not available in the LinearLayout.
Removed the Map, and its working fine.
SingleWeatherInfoView.java - line 41
public SingleWeatherInfoView(Context context, AttributeSet attrs,
Map inflateParams) {
super(context, attrs, inflateParams);
Thank you so much.
|
|
| Back to top |
|
 |
mlw4428 Once Poster

Joined: 23 Nov 2008 Posts: 1
|
Posted: Sun Nov 23, 2008 11:49 pm Post subject: |
|
|
I sorta stumbled across this page and while it sorta doesn't relate to Android development, it is inline with the OP's subject.
I have a library I created (it's open source) that does the similar thing for .NET. If you're interested you can visit my personal site (which I won't give out to keep from making it seem like I' m spamming). You can get it by messaging me or emailing me at mlw4428 at gmail dot com.
And I certainly can feel you on the XML layout..
You can also find it by searching for GWPLNET on sourceforge. But yeah, great article, just wished I found it sooner
|
|
| Back to top |
|
 |
stanimir Freshman

Joined: 02 Dec 2008 Posts: 2
|
Posted: Tue Dec 02, 2008 10:45 pm Post subject: Re: Android Weather Forecast - Google Weather API - Descript |
|
|
| Java: | Button cmd_submit = (Button)findViewById(R.id.cmd_submit);
cmd_submit.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
URL url;
try {
/* Get what user typed to the EditText. */
String cityParamString =
((EditText)findViewById(R.id.edit_input))
.getText().toString();
String queryString =
"http://www.google.com/ig/api?weather="
+ cityParamString;
/* Replace blanks with HTML-Equivalent. */
url = new URL(queryString.replace(" ", "%20"));
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
GoogleWeatherHandler gwh = new GoogleWeatherHandler();
xr.setContentHandler(gwh);
/* Parse the xml-data our URL-call returned. */
xr.parse(new InputSource(url.openStream()));
/* Our Handler now provides the parsed weather-data to us. */
WeatherSet ws = gwh.getWeatherSet();
/* Update the SingleWeatherInfoView with the parsed data. */
updateWeatherInfoView(R.id.weather_today, ws.getWeatherCurrentCondition());
updateWeatherInfoView(R.id.weather_1, ws.getWeatherForecastConditions().get(0));
updateWeatherInfoView(R.id.weather_2, ws.getWeatherForecastConditions().get(1));
updateWeatherInfoView(R.id.weather_3, ws.getWeatherForecastConditions().get(2));
updateWeatherInfoView(R.id.weather_4, ws.getWeatherForecastConditions().get(3));
} catch (Exception e) {
resetWeatherInfoViews();
Log.e(DEBUG_TAG, "WeatherQueryError", e);
}
}
}); |
I have database with cities from http://www.geonames.org/export/ and use SAX parser in Java Crawler to write in database weather for each city but the SAX parser have encoding problem with weather link like this:
http://www.google.bg/ig/api?weather=Almerķa,ES&hl=en
the xml page is:
| XML: | <xml_api_reply version="1">
<weather module_id="0" tab_id="0">
<forecast_information>
<city data="Almeria, AL"/>
<postal_code data="Almerķa,ES"/> <!-- -in this line the SAX parser break --> |
I try to fix this with setEncoding to InputSource but the problem exist :)
| Java: | java.io.UTFDataFormatException: Invalid byte 2 of 3-byte UTF-8 sequence.
at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown Source)
at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) |
this is my function
| Java: | public void parseDocument (String queryString ) {
//queryString = http://www.google.bg/ig/api?weather=Almerķa,ES&hl=en
//get a factory
SAXParserFactory spf = SAXParserFactory. newInstance();
try {
//get a new instance of parser
SAXParser sp = spf. newSAXParser();
// sp.parse(queryString,this);
URL url = new URL(queryString );
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp. getXMLReader();
xr. setContentHandler(this);
/* Parse the xml-data our URL-call returned. */
InputSource src = new InputSource (url. openStream());
src. setEncoding("UTF-8");
xr. parse(src ); |
|
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
|
| Back to top |
|
 |
|
|
 |
stanimir Freshman

Joined: 02 Dec 2008 Posts: 2
|
Posted: Wed Dec 03, 2008 9:10 am Post subject: |
|
|
This is not the decision of the problem SAX parser do not work with UTF-8..
I don`t have the table with Google name of the city like Almeria and will try to use DOM Parser
|
|
| Back to top |
|
 |
AJ Quick Junior Developer

Joined: 19 Nov 2008 Posts: 16
|
Posted: Mon Dec 29, 2008 6:17 am Post subject: |
|
|
| jeffy2010 wrote: | Hi MrSnowflake.
I have resolved the issue and the app is running fine now.
The super of SingleWeatherInfoView which was extending the LinearLayout class had a parameter of "Map", which is not available in the LinearLayout.
Removed the Map, and its working fine.
SingleWeatherInfoView.java - line 41
public SingleWeatherInfoView(Context context, AttributeSet attrs,
Map inflateParams) {
super(context, attrs, inflateParams);
Thank you so much. |
I wanted to test this program out.. but I am now having the same error.
Removing Map doesn't fix it the same way it did for you.
|
|
| Back to top |
|
 |
weatherdoll Freshman

Joined: 05 Jan 2009 Posts: 2
|
Posted: Wed Jan 07, 2009 2:00 am Post subject: Thanks for the info |
|
|
Just wanted to say thanks for providing the info.
It gave me the push needed to start on my own little google weather feed app in Flash
|
|
| Back to top |
|
 |
weatherdoll Freshman

Joined: 05 Jan 2009 Posts: 2
|
Posted: Wed Jan 07, 2009 2:04 am Post subject: |
|
|
I used PHP as the proxy,
Which loads the xml AND saves a copy of the XML locally on the harddrive to prevent a flood of requests hitting google for the same weather info. It stores the local copy for 1 hour (essentally matching the Yahoo XML feed requirements).
I put most of my code and a current running sample on my website
See:
Googles weather api
Now I will start working on the client interface and get a few versions up.
|
|
| Back to top |
|
 |
EverYoung124 Freshman

Joined: 08 Dec 2008 Posts: 2
|
Posted: Tue Feb 17, 2009 8:54 pm Post subject: |
|
|
plusminus, Thank you very much for the tutorial. It is very helpful. I want to report a problem when I use it on SDK1.1-r1 and provide a solution.
First I used the source code and added the INTERNET use-permission. After installing, an error occurs when I hit the button. | Quote: | E/WeatherForecaster( 419): WeatherQuerryError
E/WeatherForecaster( 419): java.io.FileNotFoundException: http://www.google.com/ig/api?weather=Schriesheim,%20Germany
E/WeatherForecaster( 419): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1040)
E/WeatherForecaster( 419): at java.net.URL.openStream(URL.java:664)
|
However I can still get the xml file from a browser. After some testing and googling, I find that the program does not like the weather API url and I don't know why it happens. So I switched to HttpClient to open the url. What I did is replace the parse line
| Java: | xr.parse(new InputSource(url.openStream())); |
with the following
| Java: |
/* Use HTTPClient to deal with the URL */
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(queryString.replace(" ", "%20"));
Log.d(DEBUG_TAG, "executing request " + httpget.getURI());
// create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
// Log.d(DEBUG_TAG, "response from httpclient:\n "+responseBody);
ByteArrayInputStream is = new ByteArrayInputStream(responseBody.getBytes());
xr.parse(new InputSource(is));
Log.d(DEBUG_TAG, "parse complete");
// parse complete |
Then the problem goes away. Hope it might help some people.
_________________ Hang on. |
|
| Back to top |
|
 |
marmozsdx Once Poster

Joined: 15 May 2009 Posts: 1
|
Posted: Fri May 15, 2009 9:42 pm Post subject: About the Weatherbug API |
|
|
Hi guys,
I'm new to this site, and I just happen to come across this forum tutorial.
I did find it interesting that there were some issues with the Google API not accepting Lat. and Long., so I did a bit of research on the web and found out about this API from Weatherbug.com. Apparently developers need only register, confirm their account, and they are given a license to use the API.
Their API seems a lot more robust, and it allows for Lat./Long. search, so the GPS functionality can be integrated in a single step.
Here's the link to the API info: http://weather.weatherbug.com/desktop-weather/api.html
and here's a description of the API functionality: http://api.wxbug.net/help.html#compactdescr
I hope it helps you guys. I have not started work on this tutorial, but I will get started and try to implement the Weatherbug API.
Thanks for all the tutorials and the collaboration of all of you.
Francisco
|
|
| Back to top |
|
 |
Shalni Junior Developer

Joined: 29 Apr 2009 Posts: 17
|
Posted: Thu May 28, 2009 10:11 am Post subject: Weather Forecasting (1.1 V) |
|
|
Hi everybody,
Here is the weather forecasting code working on sdk 1.1 as there were some changes to be made inorder to work in 1.1 version from the original code. Hope this helps.
Thank you.
| Description: |
|
 Download |
| Filename: |
WeatherForecasting.zip |
| Filesize: |
181.36 KB |
| Downloaded: |
220 Time(s) |
|
|
| Back to top |
|
 |
armstrong Once Poster

Joined: 28 Sep 2009 Posts: 1
|
Posted: Wed Sep 30, 2009 8:59 am Post subject: |
|
|
I have this problem after entering the xml code into the main.xml.
How can i solve this problem so that my layout will appears ?
| Description: |
|
| Filesize: |
489.07 KB |
| Viewed: |
2463 Time(s) |

|
|
|
| Back to top |
|
 |
suman291857 Freshman

Joined: 12 Sep 2009 Posts: 2
|
|
| Back to top |
|
 |
|