응답 코드가 204
인 경우 서버를 다시 호출해야합니다.비동기 작업에서 if 문을 호출하는 방법은 무엇입니까?
String command = ("http://api.railwayapi.com/live/train/" + m_train_Number + "/doj/" + m_year + m_month + m_day + "/apikey/tc9sc898/");
new JSONTask().execute(command);
public class JSONTask extends AsyncTask<String, String, LiveStationModel>
{
LiveStationModel liveStationModel = null;
protected LiveStationModel doInBackground(String... params) {
IOException e;
MalformedURLException e2;
List<LiveStationModel> myList = null;
Throwable th;
JSONException e3;
HttpURLConnection connection = null;
BufferedReader reader = null;
try {
connection = (HttpURLConnection) new URL(params[0]).openConnection();
connection.connect();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
try {
StringBuffer buffer = new StringBuffer();
String str = "";
while (true) {
str = bufferedReader.readLine();
if (str == null) {
break;
}
buffer.append(str);
}
이 대답은 당신을 도울 수 ...! http://stackoverflow.com/a/6374135/7316675 – nTri