andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

Android Weather Forecast - Google Weather API - Description

Goto page Previous  1, 2, 3, 4  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials
Author Message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Tue Feb 26, 2008 11:47 am    Post subject: Reply with quote

Hello to__liuyi,

here:
XML:
<activity android:name="WeatherForecast" android:label="@string/app_name">

a Dot is missing:
XML:
<activity android:name=".WeatherForecast" android:label="@string/app_name">


Also check if somewhere is "WeatherForcast" instead of "WeatherForecast".

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
to__liuyi
Freshman
Freshman


Joined: 04 Feb 2008
Posts: 4

PostPosted: Wed Feb 27, 2008 2:31 am    Post subject: tried Reply with quote

I have tried to add the dot, it doesn't work. And I checked spelling of Weatherforecast.
Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Thu Feb 28, 2008 2:24 am    Post subject: Reply with quote

Hello to__liuyi,

I attached the working source to the end of this post: http://www.anddev.org/viewtopic.php?p=1304#1304

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
to__liuyi
Freshman
Freshman


Joined: 04 Feb 2008
Posts: 4

PostPosted: Thu Feb 28, 2008 3:08 am    Post subject: Reply with quote

well done! good job!
Back to top
View user's profile Send private message
shriya
Once Poster
Once Poster


Joined: 08 Aug 2008
Posts: 1

PostPosted: Fri Aug 08, 2008 10:12 am    Post subject: weather Info Reply with quote

If we use the Google RSS feed to take the weather data do we need to show the google trademark on our site?

It will be really helpful if I get reply immediately?


Thanks,
Shriya
Back to top
View user's profile Send private message
jujudellago
Freshman
Freshman


Joined: 13 Sep 2008
Posts: 3

PostPosted: Sat Sep 13, 2008 12:00 pm    Post subject: Reply with quote

plusminus wrote:
Hello icer,

the weather Data is openly provided by Google and therefore we can us it for free.
I don't know whether there is any document out there describing how to use the API, just use it Wink

Regards,
plusminus


Hi,

I found this very interresting topic while googling for a solution to have a dynamic weather forecast solution in a web app.

I have adapted the principle to a ruby system fetching and caching the results of the query, then parsing it with XMLSimple.

It worked really well, I just had time to run a few tests before everything got messed up... queries in my browser such as
http://www.google.com/ig/api?weather=geneva,switzerland give me no error, but fetching the datas from my program, with the same queries return something like this:
XML:

<?xml version=\"1.0\"?><xml_api_reply version=\"1\"><weather module_id=\"0\" tab_id=\"0\"><problem_cause data=\"\"/></weather></xml_api_reply>



I did not find any information on the usage of the weather API, so my feeling is that google doesn't allow such queries ... does anyone use this service ? I would love to "just use it" but I'm sure the google people are just smarter than me....

regards

julien
Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Sat Sep 13, 2008 2:53 pm    Post subject: Reply with quote

jujudellago wrote:
XML:
<?xml version=\"1.0\"?><xml_api_reply version=\"1\"><weather module_id=\"0\" tab_id=\"0\"><problem_cause data=\"\"/></weather></xml_api_reply>


Shocked Same with me here, two days ago it was still working Sad

I'll see if I can find something...

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Sat Sep 13, 2008 2:58 pm    Post subject: Reply with quote

Using a zipcode, I receive:

XML:
<xml_api_reply version="1">
<weather module_id="0" tab_id="0">
<problem_cause data="Information is temporarily unavailable."/>
</weather>
</xml_api_reply>

So lets hope its only temporary!

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jujudellago
Freshman
Freshman


Joined: 13 Sep 2008
Posts: 3

PostPosted: Sat Sep 13, 2008 4:07 pm    Post subject: Reply with quote

plusminus wrote:

Shocked Same with me here, two days ago it was still working Sad

I'll see if I can find something...

Regards,
plusminus


wow just 2 days ? I felt like these google weather tricks would just bring me troubles, and as I'm very bored today, I played around with the weather.com services...

http://www.weather.com/services/xmloap.html

not so easy to use as the google one, but it gives more complete results... well if the google weather gives you problems you can try...

regards

julien
Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Sun Sep 14, 2008 12:11 am    Post subject: Reply with quote

jujudellago wrote:
plusminus wrote:

Shocked Same with me here, two days ago it was still working Sad

I'll see if I can find something...

Regards,
plusminus


wow just 2 days ? I felt like these google weather tricks would just bring me troubles, and as I'm very bored today, I played around with the weather.com services...

http://www.weather.com/services/xmloap.html

not so easy to use as the google one, but it gives more complete results... well if the google weather gives you problems you can try...

regards

julien


Can it resolve weather for Latitude/Longitude pairs?

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jujudellago
Freshman
Freshman


Joined: 13 Sep 2008
Posts: 3

PostPosted: Sun Sep 14, 2008 1:00 pm    Post subject: Reply with quote

plusminus wrote:

Can it resolve weather for Latitude/Longitude pairs?


No, that's the "not so easy part", the queries must be made with a specific city ID, so you must fetch the city ID from a given city.

I did not find a city database for weather.com, so I populated the maxmind city database http://www.maxmind.com/app/city then I internally calculate the nearest city to query weather.com (it's all made very easy with some ruby on rails plugins...)
Back to top
View user's profile Send private message
cmveas
Freshman
Freshman


Joined: 20 Oct 2008
Posts: 2

PostPosted: Wed Oct 22, 2008 12:21 am    Post subject: Problem connecting to the weather Reply with quote

Hello Plusminus I was trying to make the example work but I have a problem when I tried to connect to the "service"

http://www.google.com/ig/api?weather=



Java:
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);
                         InputStream input = url.openStream();  ---> EXCEPTION OCCURS HERE
                         /* Parse the xml-data our URL-call returned. */
                         xr.parse(new InputSource(input));



I debugged the code and when the line InputStream input = url.openStream(); executes in throws and exception. The monitor showed me this

Java:
10-21 23:00:19.182: ERROR/WeatherForcaster(169): java.net.SocketException: [b][u]unknown error[/u][/b]
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at java.net.Socket.checkClosedAndCreate(Socket.java:763)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at java.net.Socket.connect(Socket.java:910)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1030)
10-21 23:00:19.182: ERROR/WeatherForcaster(169):     at java.net.URL.openStream(URL.java:664)


I tested the connectivity with the emulator but I can perform any search with it so I think that the internet conection must be working well so that leaves me without a clue about what must be wrong. By the way Im running the example with SDK 1.0 I hope that helps.
Any suggestion will be welcome and thanks for making available all these examples.
Back to top
View user's profile Send private message MSN Messenger
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Wed Oct 22, 2008 1:15 am    Post subject: Reply with quote

Hi cmveas,

did you add the ACCESS_INTERNET Permission to the AndroidManifest.xml Question

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cmveas
Freshman
Freshman


Joined: 20 Oct 2008
Posts: 2

PostPosted: Wed Oct 22, 2008 3:41 am    Post subject: Perfect!! Reply with quote

Thanks plusminus I did not know that! and it worked perfectly. Thanks for the help!
Claudio Veas (cmveas)
Back to top
View user's profile Send private message MSN Messenger
jeffy2010
Freshman
Freshman


Joined: 18 Nov 2008
Posts: 5

PostPosted: Tue Nov 18, 2008 3:34 pm    Post subject: Reply with quote

Hi plusminus, I am somehow not able to run your application. Sad
I have attached the console window with the error (error1.jpg).
It would be really helpful if you could tell me if I am missing out on something.

Thank you so much,
Jeff



error1.JPG
 Description:
 Filesize:  207.96 KB
 Viewed:  5289 Time(s)

error1.JPG


Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.