標籤:
Earthquake工程(地震監測) 的 對
本文地址: http://blog.csdn.net/caroline_wendy/article/details/24465487
Earthquake項目地址: http://blog.csdn.net/caroline_wendy/article/details/21976997
因為, 訂閱源地址(feed): http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.atom的資料發生更新;
所以讀取訂閱源的title標籤時, 會出現bug, 如title: <title>M 5.9 - South of the Fiji Islands</title>
資料:
<entry><id>urn:earthquake-usgs-gov:us:b000py4w</id><title>M 5.9 - South of the Fiji Islands</title><updated>2014-04-25T03:54:35.052Z</updated><link rel="alternate" type="text/html" href="http://earthquake.usgs.gov/earthquakes/eventpage/usb000py4w"/><link rel="alternate" type="application/cap+xml" href="http://earthquake.usgs.gov/earthquakes/eventpage/usb000py4w.cap"/><summary type="html"><![CDATA[<p class="quicksummary"><a href="http://earthquake.usgs.gov/earthquakes/eventpage/usb000py4w#pager" title="PAGER estimated impact alert level" class="pager-green">PAGER - <strong class="roman">GREEN</strong></a> <a href="http://earthquake.usgs.gov/earthquakes/eventpage/usb000py4w#shakemap" title="ShakeMap maximum estimated intensity" class="mmi-III">ShakeMap - <strong class="roman">III</strong></a></p><dl><dt>Time</dt><dd>2014-04-24 19:51:58 UTC</dd><dd>2014-04-24 07:51:58 -12:00 at epicenter</dd><dt>Location</dt><dd>23.991°S 176.699°W</dd><dt>Depth</dt><dd>63.53 km (39.48 mi)</dd></dl>]]></summary><georss:point>-23.9906 -176.6986</georss:point><georss:elev>-63530</georss:elev><category label="Age" term="Past Day"/><category label="Magnitude" term="Magnitude 5"/></entry>
這條資料的title沒有包括最後的國家, 所以
省略了逗號(","), 導致
EarthquakeListFragment.java類:
details = details.split(",")[1].trim();在
切分(split)時, 沒有發現逗號(","), 則僅僅包括
一個String, 使用
索引(index)1時, 發生
數組越界,
報錯: "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1"
改動為, 把逗號(",")改為減號("-"):
details = details.split("-")[1].trim();
即
位置資訊包括"地區, 國家".
著作權聲明:本文博主原創文章,部落格,未經同意不得轉載。
Android - Earthquake工程(地震監測) 的 對