메인 C# 및 Java에서 개발하기 시작했다. 나는 스레드 :(나는 무시 run() 메소드에서 브레이크 포인트를 설정 한, 아무것도이 방법 내에서 실행 것 같다(자바) 스레드가 실행되지 않습니다
public class GetLocationInfo implements Runnable{
String address;
double latitude;
double longitude;
public void run() {
HttpGet httpGet = new HttpGet("http://maps.google.com/maps/api/geocode/json?latlng=42.993504,-79.239167&sensor=false");
//HttpGet httpGet = new HttpGet("http://maps.google.com/maps/api/geocode/json?latlng="+latitude+","+longitude+"&sensor=false");
HttpClient client = new DefaultHttpClient();
HttpResponse response;
try {
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
JsonReader reader = new JsonReader(new InputStreamReader(stream, "UTF-8"));
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("formatted_address")) {
address = reader.nextString();
} else
reader.skipValue();
}
reader.endObject();
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
}
public String GetAddress(double lat, double lng) {
latitude = lat;
longitude = lng;
Thread thread = new Thread(this);
thread.start();
return address;
}
}
를 시작하는 데 문제가 있어요. 너희들이 내가 그것을이 똑 바르게 도울 수있는 경우 많이 주시면 감사하겠습니다.
건배
캐치 블록을 비워 두었습니다. 각 catch 블록에'e.printStackTrace();'를 추가하고 예외가 던져 졌는지 확인하십시오. – Blackbelt
방금 스레드를 시작했습니다. 이미'주소 '가 채워질 것이라고 어떻게 생각하십니까? – njzk2