[問題] geocoder

看板AndroidDev作者 (AniviaGod)時間10年前 (2015/03/21 15:14), 編輯推噓1(105)
留言6則, 4人參與, 最新討論串1/1
小弟想要用Geocoder把經緯度轉成地址 可是使用geocoder.getFromLocation時每次都會跑出ERROR 請問是哪裡寫錯了嗎? 還是有什麼除了Internet以外的Permission public String getAddress(){ Geocoder gc = new Geocoder(this, Locale.ENGLISH); String place=null; try { List<Address> lstAddress = gc.getFromLocation(longitude, latitude,1); place = lstAddress.get(0).getLocality(); } catch (IOException e) { } return place; } 感謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.133.36.13 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1426922071.A.2D6.html

03/21 22:06, , 1F
locat 錯誤是什麼?
03/21 22:06, 1F

03/22 17:43, , 2F
給個錯誤訊息是基本要求吧?很難隔空抓藥。
03/22 17:43, 2F

03/23 09:08, , 3F
你把IO兩個字去掉就好了
03/23 09:08, 3F

03/23 15:24, , 4F
lstAddress可能沒結果 你直接call get(0) so danger
03/23 15:24, 4F

03/23 15:24, , 5F
ous
03/23 15:24, 5F

03/23 15:27, , 6F
另外你應該要先檢查 Geocoder.isPresent()
03/23 15:27, 6F
文章代碼(AID): #1L3HfNBM (AndroidDev)