First, the project shows the following results:
Project Source code:
Http://yunpan.cn/cZVWIieuFyK9I Access Password 2EAC
Second, using the Aggregation Data SDK:
(1) I am using the aggregate data on the weather forecast query, address: http://www.juhe.cn/
(2) Register your account-Create a new app (in the Personal Center page-Data Center-request data) – Fill in your application – Find categories – weather forecast – National Weather forecast
(3) Download the SDK (since the project uses 1-point versions, please download: Included in my project!) )
(4) Reference development document: Http://www.juhe.cn/juhesdk/adocs
The following describes the initialization of the aggregation data SDK and the use of permissions!
Iii. Introduction of the project
(1) Project
(2) Weatherapplication.java here as an initialization of the SDK
Package Com.juhe.weather;import Com.thinkland.juheapi.common.commonfun;import android.app.application;/* Here is the SDK that initializes the aggregated data needs to be added to the application 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 the process Commonfun.initialize (Getapplicationcontext ());} }
We need to include the following in the manifest file:
Android:name= "Com.juhe.weather.WeatherApplication"
(3) The JSON data format returned
{"ResultCode": "$", "Reason": "successed!", "result": {"SK": {"temp": "+", "WI Nd_direction ":" Northwest Wind "," wind_strength ":" Level 1 "," humidity ":" 37% "," Time ":" 16:00 "}, "Today": {"Temperature": "5℃~19℃", "Weather": "Cloudy", "weather_id": { "FA": "Week", "FB": "The", "The Wind": "Southerly Breeze", "the" "Friday", " City ":" Chengdu "," date_y ":" March 13, 2015 "," Dressing_index ":" More Comfortable "," dressing_advice ":" Recommended thin coat , cardigan denim shirt pants and other clothing. The frail and infirm should be suitably added clothing, suitable for jackets, thin sweaters and so on. "," Uv_index ":" Weakest "," Comfort_index ":" "," Wash_index ":" More Appropriate "," Travel_index ": "", "Exercise_index": "Less appropriate", "Drying_index": "}," future ": {" day_201503 ": {" Temperature ":" 5℃~19℃ "," Weather ":" Cloudy "," weather_id ": { "FA": "The", "FB": "The" "" "," Wind ":" South Breeze ", "Week": "Friday", "date": "20150313"}, "day_20150319": {"Temperatur E ":" 10℃~18℃ "," Weather ":" Yin "," weather_id ": {" FA ":" 02 ", "FB": "Week"}, "Wind": "Southerly Breeze", "the" "Thursday", "date": "201 50319 "}}}," Error_code ": 0} JSON data format for the next three days: {" ResultCode ":" $ "," Reason ":" successed! ", "Result": [{"Weatherid": "The", "Weather": "Cloudy", "Temp1": "+", "Temp2": "+", "sh": "+", "eh": "A", "date": "20150313", "sfdate": "20150313170000", "efdate": "20150313200000" }, {"Weatherid": "Up", "Weather": "Yin", "temp1": "+", "Temp2": "+", "sh": "11", "Eh": "17", "Date": "20150320", "sfdate": "20150320110000", "efdate": "20150320170000"}], "Error_code": 0}
(4) According to the above JSON format, we need to create the corresponding JSON question object, in order to better deal with, respectively, to establish the corresponding class
Is the JSON data containing the relationship, error-prone! Hereby mark it out!
(5) Weatherservice.java is mainly processing the background service class, the loading of data in the background!
Note that the following are:
The value of the white part here is the OpenID (which can be found in the center of the Personal Center) when applying on aggregated data openid! )
Android Program National Weather Query Interface Demo