In this article we will elaborate how to receive the weather detail from the yahoo website based on the country zip codes. Once you retrieved the result from yahoo
website, you can display on the GUI. Actually this would be useful for people who are working with generally service application in windows mobile devices.
Since most of people (assume like all) are using mobile phones, they all are like to have everything on that. Since from that idea, we will elaborate how to retrieve the public information (such as weather, Stock exchange, currency exchange detail) from Yahoo/Google service or API and display on the windows mobile device.
In this article we have taken the weather detail as example and elaborate how to access the weather information from the yahoo service by using zip code.
1. Windows Mobile 6 SDK
2. Windows Mobile 5/6 Professional Emulator.
3. Visual Studio 2008
Here we must understand how a web request and response are working. Because of its complete request and response operations in windows mobile, from that response we are going to do some formatting to get the appropriate data (values) from the stream.
Actually here we have designed a very nice user interface, when the user access the weather info application, Interface must attract the user. (though it is very common for other applications too).
And we are not going to explain about how to design the GUI, because most of the time we have explained in our previous articles and it waste time also.
You can see my GUI as shown below and also download my sample project on end of the article.
This is very handy and user friendly User interface. Here we are going to display temperature details lowest and highest reading, which is return from the yahoo service. And also display the image according to temperature value.
Actually implementation is very easy because of yahoo Service have already been done all main functionality for this weather information services.
So you just have to read that stream which you get from the from the response and do few line code formatting to extract figures and then display on the screen.
But now you can imagine how we are receiving response stream from the yahoo service. For that we need to create a request object like following.
First you must create request object it originally as webrequest, then you must cast to HTTP request.
Then you can set timeout and which method you are going to use(GET,POST). And then you have to create response from the request that already had been created.
Then we need to get response stream from the response and cast to normal stream.
After that we are calling another method that is doing all type of formatting and display to screen.
Before we talk about formatting section implementation, you must do dispose or close request, response and stream objects.Because of these resources more memory is streamed on the system.
So when you finished your access code for the request,response and stream objects then write code that under that finally block. Like following.
Now let’s look formatting implementation method. Actually there we going to extra figures from the string. So we think don’t post the full code of that method, because it will take more space on the article. Since signature of that method. One more you can download our code end of this article.
Now you call the GetLastInfor() method within ourrm load event and also Refresh menu click event. Which should be like below.
Now you build the application and then run result will be like following figure( for an example I have used,29450 as zip code).
The Result User Interface figure
In this article we have elaborated, how to access the Yahoo public service and extract useful information and display that on the windows mobile devices.
In our next article we will explain how to retrieve from Google public API and service and get useful information on the windows mobile device.
- 4+ years experience in C#.net,VB.net adn JAVA.
B.Sc. degree in Computer Science.
- Obsessed in OOP style design and programming.
- Designing and developing Network security tools.
- Designing and developing a client/server application for sharing files among users in a
way other than FTP protocol.
- Designing and implementing GSM gateway applications and bulk messaging.
- Windows Mobile and Symbian Programming
- Having knowledge with ERP solutions
The summary of my skills:
C#, VB.Net#,ASP.net, VC++, Java, WPF,WCF, SilverLight,Oracle,PL/SQL, SQL Server, MS Access
My Web Blogs