Android Program National Weather Forecast query interface call

Source: Internet
Author: User
Tags openid

First, the project shows the following results:

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-87357a9a8a909025?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>


650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-301ec100a0930e2a?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>


Project Source code:

Http://yunpan.cn/cZVWIieuFyK9I Access Password 2EAC

Second, using the Aggregation Data SDK:

(1) Aggregated data official website 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

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-68b6c0f74ed59dd2?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

(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

This article describes the initialization of the aggregation data SDK and the use of permissions!

Iii. Introduction of the project

(1) Project


650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-c8a8716ebe16d774?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

(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 for initializing aggregated data  *  *  need to add  android:name= "com.juhe.weather.weatherapplication * in Application   *  @author  xuliugen *  */public class WeatherApplication  extends application {     @Override     public void  OnCreate ()  {        super.oncreate ();         //  the process required to initialize using the Aggregation SDK          Commonfun.initialize (Getapplicationcontext ());     }} 

We need to include the following in the manifest file:

Android:name= "Com.juhe.weather.WeatherApplication"

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-c7628c09e8182dfa?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

(3) returns the JSON data format

{     "ResultCode":  ",    " Reason ": " successed! ", "     "Result": {         "SK": {              "Temp":  ",     "         "Wind_direction":  "Northwest Wind",              "Wind_strength":  "Level 1",              "Humidity":  "37%",              "Time":  "16:00"         },          "Today": {              "Temperature":  "5℃~19℃",              "Weather":  "Cloudy",             "weather_id": {                  "FA":  ",    "              "FB":  "Up"              },              "Wind":  "Southerly Breeze",             "Week":  "Friday",             "City":  "Chengdu",              "date_y":  "March 13, 2015",              "Dressing_index":  "more Comfortable",              "Dressing_advice":  "recommends a thin jacket, cardigan denim shirt pants and other clothing. The frail and infirm should be suitably added clothing, suitable for jackets, thin sweaters and so on. ",  &Nbsp;           "Uv_index":  "weakest",              "Comfort_index":  "",              "Wash_index":  "more appropriate",              "Travel_index":  "",              "Exercise_index":  "less suitable",              "Drying_index":  ""         },          "Future": {             "Day _20150313 ": {                  "Temperature":  "5℃~19℃",                 " Weather ": " Cloudy ",                  "weather_id": {                      "FA":  ",        "              "FB":  "Up"                  },                  "Wind":  "Southerly Breeze",                  "Week":  "Friday",                  "Date":  "20150313"              },              " day_20150319 ": {                  "Temperature":  "10℃~18℃",                  "Weather":  "Yin",                  "weather_id": {                      "FA":  ",    "                  "FB":  "02 "                },                  "Wind":  "Southerly Breeze",                  "Week":  " Thursday ",   &NBsp;              "Date":  "20150319"              }         }    },     "Error_code":  0} JSON data format for the next three days:{      "ResultCode":  ",    " "Reason":  "successed!",      "Result": [{         "Weatherid":  ",  "        "Weather":  "Cloudy",         " Temp1 ": " ",        " Temp2 ": ",          "sh":  ",        " eh ": ",          "Date":  "20150313",          "Sfdate":  "20150313170000 ",        " Efdate ": " 20150313200000 "     },    {         "Weatherid":  ", "         "Weather":  "Yin",         "Temp1":  ",        " Temp2 ": ",     "      "sh":  "one",         "eh":  ", "         "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

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-eefad7b7ebbafc9e?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-393528a81bb4c951?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

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:

650) this.width=650; "Src=" http://upload-images.jianshu.io/upload_images/2699888-545d8100be25b7ab?imageMogr2/ auto-orient/strip%7cimageview2/2/w/1240 "class=" Imagebubble-image "style=" height:auto;vertical-align:middle; border:0px; "alt=" 1240 "/>

The value of the white part here is the OpenID at the time of application on the aggregated data (in the center of the Personal Center home page can be found openid! )


Android Program National Weather Forecast query interface call

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.