android天氣預報api
① 天氣預報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,解析一下顯示在控制項里就可以了!