private void GetNowLoc(Double... location) {
final double lat = location[0];
final double lon = location[1];
pDlg = ProgressDialog.show(BbabangMain.this, "", getString(R.string.main_nowloc_search), true);
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
}
});
getNowLoc(lat, lon);
}
}).start();
}
public void getNowLoc(Double... location) {
final double mLat = location[0];
final double mLon = location[1];
try {
runOnUiThread(new Runnable() {
public void run() {
Geocoder gc = new Geocoder(BbabangMain.this, Locale.KOREAN);
String addressString = "No address found";
try {
List<Address> addresses = gc.getFromLocation(mLat, mLon, 1);
StringBuilder sb = new StringBuilder();
if (addresses.size() > 0) {
Address address = addresses.get(0);
for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
sb.append(address.getAddressLine(i)).append("\n");
sb.append(address.getAdminArea()).append(" "); // 시
sb.append(address.getLocality()).append(" "); // 구
sb.append(address.getThoroughfare()).append(" "); // 동
addressString = sb.toString();
}
NowLocSearchDialog(addressString, mLat, mLon);
pDlg.dismiss();
} catch (IOException e) {
e.printStackTrace();
}
}
});
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
위 코드처럼
Geocoder로 현재 위치를 입력하면 주소를 받아오고 있습니다.
궁금한 점이 이때 만약 10초던 20초던 데이터를 받아오지 못하는 경우 프로그레스다이얼로그가 계속 돌고있습니다.
timeout설정을 하려면 어떻게 해야할까요?ㅠㅠ