当前位置:首页 » 安卓系统 » android天气预报api

android天气预报api

发布时间: 2022-09-14 02:09:51

① 天气预报API接口是什么

天气预报API接口是气象服务商为客户提供服务的唯一接口。拿墨迹赤必为例,跟客户充分沟通后了解客户的实际需求,从而对现有的数据进行调整,符合客户的需求形成API接口,让客户接入,这样就形成了一个完整的服务。所以说API接口并不是一个很神秘的东西,只不过是企业和客户之间的一条服务纽带。

② android 如何实现获取天气预报信息

方法步骤(以安卓5.0为例)

一、打开GPS

九、提示

1.适时刷新天气需要开启GPS定位。

2.在没有WIFI的地方刷新天气需要消耗一定的流量,刷新频率越高,消耗流量越多。

③ 求源码参考,android编写天气预报,如何根据城市的名字,利用雅虎天气或者中国天气网的api,把天气显示出来呢

你先去找到他们网址的api,看懂api文档了解了参数。然后注册api开发。 写一个类去获取数据,然后再解析。

④ Android weather API 昨天好像发现 m.weather.com.cn/data

这是官方论坛上的通知,那个接口已经停用,可以申请新的接口使用,谢谢。

致广大气象开发爱好者:
近期很多网友反馈http://m.weather.com.cn/data/101010100.html该地址的数据不更新,特此声明,该地址并非官方发布的面向公众的数据接口。后续将不在维护!

如需使用天气数据,请到官方正式对外提供的平台(SmartWeatherAPI平台),按固定格式填写表格申请使用:

申请地址:http://smart.weather.com.cn/wzfw/smart/weatherapi.shtml

该接口免费向公众提供3天天气预报、实况、指数等数据信息,如需申请开通更多数据接口,请走商务合作渠道!

感谢大家配合!

⑤ ​android软件开发:中国气象局api接口(显示4、5天的天气),能实际有用的,日期也得正确

中国国家气象局天气预报接口总共提供了三个:

http://www.weather.com.cn/data/sk/101010100.html

http://www.weather.com.cn/data/cityinfo/101010100.html

http://m.weather.com.cn/data/101010100.html

最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变城市代码,就可以得到所在城市的天气信息。笔者在福州,所以选择的城市代码是福州101230101。
在浏览器上输入url:http://m.weather.com.cn/data/101230101.html得到信息,天气信息是json的数据格式,数据如

{"weatherinfo":{"city":"福州","city_en":"fuzhou","date_y":"2012年5月14日","date":"","week":"星期一","fchh":"08","cityid":"101230101","temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃","tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉","weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨","img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3","img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨","wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风","fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级","index":"热","index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。","index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。","index_uv":"弱","index48_uv":"最弱","index_xc":"不宜","index_tr":"适宜","index_co":"较不舒适","st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18","index_cl":"较不宜","index_ls":"不太适宜","index_ag":"不易发"}}[/code]
我们可以解析json数据去得到自己想用的天气信息。
天气信息解释:
{
"weatherinfo":{
<!--基本信息-->
"city":"福州",
"city_en":"fuzhou",
"date_y":"2012年5月14日",
"date":"",
"week":"星期一",
"fchh":"08",
"cityid":"101230101",
<!--从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度-->
"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",
<!--从今天开始到第六天的每天的天气情况,这里的温度是华氏温度-->
"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",
<!--天气描述-->
"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",
<!--天气描述图片序号-->
"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",
<!--图片名称-->
"img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨",
<!--风速描述-->
"wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",
<!--风速级别描述-->
"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",
<!--今天穿衣指数-->
"index":"热",
"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",
<!--48小时穿衣指数-->
"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",
<!--紫外线及48小时紫外线-->
"index_uv":"弱","index48_uv":"最弱",
<!--洗车-->
"index_xc":"不宜",
<!--旅游-->
"index_tr":"适宜",、
<!--舒适指数-->
"index_co":"较不舒适",
"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",
<!--晨练-->
"index_cl":"较不宜",
<!--晾晒-->
"index_ls":"不太适宜",
<!--过敏-->
"index_ag":"不易发"
}
}

⑥ 安卓开发如何获取天气API

可以看一下这个,看能否对你有所帮助。
Android开发_android如何通过Google Weather Api 获取天气预报
信息
来源网络文库:http://wenku..com/view/68815ab5fd0a79563c1e7254.html

⑦ android怎样使用天气预报接口 实现天气预报

使用搜索引擎可以得到很多的天气预报接口,这里以某个api为例

http://wthrcdn.etouch.cn/WeatherApi

参数为city=城市名称

尝试获取南昌的天气预报

http://wthrcdn.etouch.cn/WeatherApi?city=南昌


得到下面xml数据

java"><?xmlversion="1.0"encoding="utf-8"?>

<resp>
<city>南昌</city>
<updatetime>16:55</updatetime>
<wen>5</wen>
<fengli>3级</fengli>
<shi>90%</shi>
<fengxiang>北风</fengxiang>
<sunrise_1>06:54</sunrise_1>
<sunset_1>17:19</sunset_1>
<sunrise_2/>
<sunset_2/>
<environment>
<aqi>26</aqi>
<pm25>13</pm25>
<suggest>各类人群可自由活动</suggest>
<quality>优</quality>
<MajorPollutants/>
<o3>44</o3>
<co>1</co>
<pm10>14</pm10>
<so2>4</so2>
<no2>27</no2>
<time>16:00:00</time>
</environment>
<yesterday>
<date_1>4日星期五</date_1>
<high_1>高温11℃</high_1>
<low_1>低温7℃</low_1>
<day_1>
<type_1>阴</type_1>
<fx_1>无持续风向</fx_1>
<fl_1>微风</fl_1>
</day_1>
<night_1>
<type_1>小到中雨</type_1>
<fx_1>北风</fx_1>
<fl_1>3-4级</fl_1>
</night_1>
</yesterday>
<forecast>
<weather>
<date>5日星期六</date>
<high>高温7℃</high>
<low>低温5℃</low>
<day>
<type>中到大雨</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</day>
<night>
<type>小到中雨</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</night>
</weather>
<weather>
<date>6日星期天</date>
<high>高温10℃</high>
<low>低温5℃</low>
<day>
<type>阴</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</day>
<night>
<type>多云</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</night>
</weather>
<weather>
<date>7日星期一</date>
<high>高温13℃</high>
<low>低温6℃</low>
<day>
<type>多云</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</day>
<night>
<type>晴</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</night>
</weather>
<weather>
<date>8日星期二</date>
<high>高温13℃</high>
<low>低温7℃</low>
<day>
<type>晴</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</day>
<night>
<type>多云</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</night>
</weather>
<weather>
<date>9日星期三</date>
<high>高温13℃</high>
<low>低温10℃</low>
<day>
<type>小雨</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</day>
<night>
<type>小雨</type>
<fengxiang>无持续风向</fengxiang>
<fengli>微风级</fengli>
</night>
</weather>
</forecast>
<shus>
<shu>
<name>晨练指数</name>
<value>不宜</value>
<detail>有较强降水,请避免户外晨练,建议在室内做适当锻炼,保持身体健康。</detail>
</shu>
<shu>
<name>舒适度</name>
<value>较舒适</value>
<detail>白天有雨,人们会感到有些凉意,但大部分人完全可以接受。</detail>
</shu>
<shu>
<name>穿衣指数</name>
<value>较冷</value>
<detail>建议着厚外套加毛衣等服装。年老体弱者宜着大衣、呢外套加羊毛衫。</detail>
</shu>
<shu>
<name>感冒指数</name>
<value>极易发</value>
<detail>将有一次强降温过程,天气寒冷,且空气湿度较大,极易发生感冒,请特别注意增加衣服保暖防寒。</detail>
</shu>
<shu>
<name>晾晒指数</name>
<value>不宜</value>
<detail>有较强降水,不适宜晾晒。若需要晾晒,请在室内准备出充足的空间。</detail>
</shu>
<shu>
<name>旅游指数</name>
<value>较不宜</value>
<detail>天气稍凉,有微风,同时有有较强降水,会给出行产生很多麻烦,建议好还是多选择在室内活动!。</detail>
</shu>
<shu>
<name>紫外线强度</name>
<value>最弱</value>
<detail>属弱紫外线辐射天气,无需特别防护。若长期在户外,建议涂擦SPF在8-12之间的防晒护肤品。</detail>
</shu>
<shu>
<name>洗车指数</name>
<value>不宜</value>
<detail>不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。</detail>
</shu>
<shu>
<name>运动指数</name>
<value>较不宜</value>
<detail>有较强降水,建议您选择在室内进行健身休闲运动。</detail>
</shu>
<shu>
<name>约会指数</name>
<value>不适宜</value>
<detail>较强降水天气会给室外约会增添许多麻烦,尽量不要外出约会,最好在室内促膝谈心。</detail>
</shu>
<shu>
<name>雨伞指数</name>
<value>带伞</value>
<detail>有较强降水,您在外出的时候一定要带雨伞,以免被雨水淋湿。</detail>
</shu>
</shus>
</resp>


得到数据后使用XML解析数据即可,最好是建立一个实体类来存储数据

下面是使用DOM方式解析部分数据代码

DocumentBuilderbuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
//is是网络连接得到的输入流
Documentdoc=builder.parse(is);
if(doc==null)thrownewException();

Elementelement=doc.getDocumentElement();
NodeListchildList=element.getChildNodes();
for(inti=0;i<childList.getLength();i++){
Elemente=(Element)childList.item(i);
Stringtag=e.getTagName();
Stringtext=e.getTextContent();
if("city".equals(tag)){
//城市
}elseif("updatetime".equals(tag)){
//更新时间
}elseif("wen".equals(tag)){
//即时温度
}elseif("fengli".equals(tag)){
//风力
}elseif("shi".equals(tag)){
//湿度
}elseif("fengxiang".equals(tag)){
//风向
}
}

⑧ android端免费获取天气信息的服务器接口有么

中国国家气象局提供了获取所在城市天气预报信息接口。通过这个接口,我们就可以获取天气信息了。

关于获取天气预报的实例参考android学习手册,里面有源码。android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳

中国国家气象局天气预报接口总共提供了三个:


http://www.weather.com.cn/data/sk/101010100.html

http://www.weather.com.cn/data/cityinfo/101010100.html

http://m.weather.com.cn/data/101010100.html

注:上面接口2014.3.4日已不再更新。换成这个:http://m.weather.com.cn/atad/101230201.html。各位看34楼。在此感谢tdwll和黄晓佳cobish。

最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变城市代码,就可以得到所在城市的天气信息。笔者在福州,所以选择的城市代码是福州101230101。

在浏览器上输入url:http://m.weather.com.cn/data/101230101.html得到信息,天气信息是json的数据格式,数据如下:

{"weatherinfo":{"city":"福州","city_en":"fuzhou","date_y":"2012年5月14日","date":"","week":"星期一","fchh":"08","cityid":"101230101","temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃","tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉","weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨","img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3","img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨","wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风","fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级","index":"热","index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。","index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。","index_uv":"弱","index48_uv":"最弱","index_xc":"不宜","index_tr":"适宜","index_co":"较不舒适","st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18","index_cl":"较不宜","index_ls":"不太适宜","index_ag":"不易发"}}


我们可以解析json数据去得到自己想用的天气信息。


天气信息解释:


[html] view plain print?

{

"weatherinfo":{

<!--基本信息-->

"city":"福州",

"city_en":"fuzhou",

"date_y":"2012年5月14日",

"date":"",

"week":"星期一",

"fchh":"08",

"cityid":"101230101",

<!--从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度-->

"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",

<!--从今天开始到第六天的每天的天气情况,这里的温度是华氏温度-->

"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",

<!--天气描述-->

"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",

<!--天气描述图片序号-->

"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",

<!--图片名称-->

"img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨",

<!--风速描述-->

"wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",

<!--风速级别描述-->

"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",

<!--今天穿衣指数-->

"index":"热",

"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",

<!--48小时穿衣指数-->

"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",

<!--紫外线及48小时紫外线-->

"index_uv":"弱","index48_uv":"最弱",

<!--洗车-->

"index_xc":"不宜",

<!--旅游-->

"index_tr":"适宜",、

<!--舒适指数-->

"index_co":"较不舒适",

"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",

<!--晨练-->

"index_cl":"较不宜",

<!--晾晒-->

"index_ls":"不太适宜",

<!--过敏-->

"index_ag":"不易发"

}

}

{
"weatherinfo":{
<!-- 基本信息 -->
"city":"福州",
"city_en":"fuzhou",
"date_y":"2012年5月14日",
"date":"",
"week":"星期一",
"fchh":"08",
"cityid":"101230101",
<!-- 从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度 -->
"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",
<!-- 从今天开始到第六天的每天的天气情况,这里的温度是华氏温度 -->
"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",
<!-- 天气描述 -->
"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",
<!-- 天气描述图片序号 -->
"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",
<!-- 图片名称 -->
"img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨",
<!-- 风速描述 -->
"wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",
<!-- 风速级别描述 -->
"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",
<!-- 今天穿衣指数 -->
"index":"热",
"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",
<!-- 48小时穿衣指数 -->
"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",
<!-- 紫外线及48小时紫外线 -->
"index_uv":"弱","index48_uv":"最弱",
<!-- 洗车 -->
"index_xc":"不宜",
<!-- 旅游 -->
"index_tr":"适宜",、
<!-- 舒适指数 -->
"index_co":"较不舒适",
"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",
<!-- 晨练 -->
"index_cl":"较不宜",
<!-- 晾晒 -->
"index_ls":"不太适宜",
<!-- 过敏 -->
"index_ag":"不易发"
}
}

⑨ android 高德2.10如何获取天气预报啊

恩,调用谷歌天气预报的api,返回xml,解析一下显示在控件里就可以了!

热点内容
公司建设网站怎么搭建服务器 发布:2025-01-08 11:45:43 浏览:302
dell存储分类 发布:2025-01-08 11:40:02 浏览:712
递归sql语句 发布:2025-01-08 11:31:50 浏览:708
laravel缓存文件 发布:2025-01-08 11:31:46 浏览:631
怎么看macbook配置信息 发布:2025-01-08 11:27:40 浏览:61
python带路径的文件 发布:2025-01-08 11:23:22 浏览:713
如何把手机内容存储 发布:2025-01-08 11:09:34 浏览:245
三星联系人存储程序停止 发布:2025-01-08 11:09:26 浏览:424
qq编程语言 发布:2025-01-08 11:04:26 浏览:39
安卓系统玩的王者荣耀怎么转苹果 发布:2025-01-08 11:02:21 浏览:850