과 같은 다른 데이터없이 url에서 응답 코드를받습니다. 호출을 식별하기위한 응답 코드 (예 : 200)가 필요하지만 필요는없는 서버 URL 호출이 필요합니다. json과 같은 다른 데이터.(html 또는 xml 또는 json)
내가 독자 객체를 구현하기 위해 (inputStreamReader)를 싶지 않는 즉와 즐 즐 즐 ..
그래서 코드가 될 것입니다 호출 URL GET 응답 코드 종료
과 같은 다른 데이터없이 url에서 응답 코드를받습니다. 호출을 식별하기위한 응답 코드 (예 : 200)가 필요하지만 필요는없는 서버 URL 호출이 필요합니다. json과 같은 다른 데이터.(html 또는 xml 또는 json)
내가 독자 객체를 구현하기 위해 (inputStreamReader)를 싶지 않는 즉와 즐 즐 즐 ..
그래서 코드가 될 것입니다 호출 URL GET 응답 코드 종료
당신은 그런 일을 수행 할 수 있습니다
HttpGet httpRequest = new HttpGet(myUri);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpRequest);
response.getStatusLine().getStatusCode(); // Your status-code
사용 상태 코드 :
HttpGet get = new HttpGet(url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(get);
int code = response.getStatusLine().getStatusCode()
아래 코드를 사용해보십시오 :
URL obj = new URL("http://www.google.com/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// you can set the required parameter for your connection object
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
이 귀하의 게시물에에서 방법을 실행하시기 바랍니다 시도를 비동기식 :
StringBuilder builder = new StringBuilder();
// Set up HTTP post
// HttpClient is more then less deprecated. Need to change to URLConnection
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
//do some work
}
이 작업을 수행 할 비행기는 무엇입니까? – Sree
인프라가 작동하는 방식이 아닙니다. int 응답을 얻는 것만으로는 잡을 필요가 있고 무시할 수있는 많은 다른 정보로 감싸집니다. – indivisible
안녕하세요, @sky –