Android Program-National Weather Forecast query (aggregated data development), android Weather Forecast

Source: Internet
Author: User
Tags openid

Android Program-National Weather Forecast query (aggregated data development), android Weather Forecast

I. project demonstration effect:

Project source code:
Http://yunpan.cn/cZVWIieuFyK9I access password 2eac

Ii. Use the aggregate data SDK:
(1) aggregated data official website address: http://www.juhe.cn/

(2) register an account-create a new application (on the personal Center page-Data Center-apply for data)-enter your application-find category-Weather Forecast-National Weather Forecast

(3) download the sdk (because the project uses a version of, please download: Included in my project !)
(4) Reference development documents: http://www.juhe.cn/juhesdk/adocs

This section describes the initialization and permission usage of the aggregate data SDK!

Iii. Project Introduction

(1) project

(2) WeatherApplication. java is used as sdk initialization.

Package com. juhe. weather; import com. thinkland. juheapi. common. commonFun; import android. app. application;/*** here is the SDK for initializing aggregated data. ** you need to add android: name = "com. juhe. weather. weatherApplication ** @ author xuliugen **/public class WeatherApplication extends Application {@ Override public void onCreate () {super. onCreate (); // use the aggregation SDK to initialize CommonFun. initialize (getApplicationContext ());}}

We need to add the following to the configuration file:

android:name="com.juhe.weather.WeatherApplication"


(3) returned json Data Format

{"Resultcode": "200", "reason": "successed! "," Result ": {" sk ": {" temp ":" 19 "," wind_direction ":" northwest wind "," wind_strength ":" Level 1 ", "humidity": "37%", "time": "16:00"}, "today": {"temperature": "5 ℃ ~ 19 ℃ "," weather ":" Cloudy to overcast "," weather_id ": {" fa ":" 01 "," fb ":" 02 "}," wind ": "Nanfeng Breeze", "week": "Friday", "city": "Chengdu", "date_y": "August March 13, 2015", "dressing_index": "More comfortable ", "dressing_advice": "We recommend that you wear thin coats, denim shirts, and other clothing. Old and weak people should add appropriate clothing, and should wear jackets and thin sweaters. "," Uv_index ":" weakest "," comfort_index ":" "," pai_index ":" More suitable "," travel_index ":" "," exercise_index ": "Not suitable", "drying_index": ""}, "future": {"day_20150313": {"temperature": "5 ℃ ~ 19 ℃ "," weather ":" Cloudy to overcast "," weather_id ": {" fa ":" 01 "," fb ":" 02 "}," wind ": "Nanfeng Breeze", "week": "Friday", "date": "20150313"}, "day_20150319": {"temperature": "10 ℃ ~ 18 ℃ "," weather ":" Overcast "," weather_id ": {" fa ":" 02 "," fb ":" 02 "}," wind ": "Nanfeng Breeze", "week": "Thursday", "date": "20150319" }}, "error_code": 0} json data format for the next three days: {"resultcode": "200", "reason": "successed! "," Result ": [{" weatherid ":" 01 "," weather ":" Multi-cloud "," temp1 ":" 16 "," temp2 ":" 13 ", "sh": "17", "eh": "20", "date": "20150313", "sfdate": "20150313170000", "efdate ": "20150313200000" },{ "weatherid": "02", "weather": "Yin", "temp1": "19", "temp2": "16 ", "sh": "11", "eh": "17", "date": "20150320", "sfdate": "20150320110000", "efdate ": "20150320170000"}], "error_code": 0}

(4) based on the preceding json format, we need to create corresponding json question objects. For better processing, we need to create corresponding classes respectively.


Contains json data containing links, which is prone to errors! Mark it!

(5) WeatherService. java is mainly used to process Background services and load data in the background!

Note:

Here, the value of the white part is the OpenID applied for on the aggregated data (you can find the OpenID on the home page of the personal center !)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.