나는 다음과 같은 클래스가 :AsyncTask에서 문자열을 다시 얻는 방법은 무엇입니까?
public class getURLData extends AsyncTask<String, Integer, String>{
@Override
protected String doInBackground(String... params) {
String line;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(params[0]);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (MalformedURLException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
} catch (IOException e) {
line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
}
return line;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
내가 같이 호출하는 것을 시도하고있다 : 출력 변수가 데이터를 받고 있지 않습니다
String output = null;
output = new getURLData().execute("http://www.domain.com/call.php?locationSearched=" + locationSearched);
하지만, 오류가 점점 오전 대신 :
Type mismatch: cannot convert from AsyncTask<String,Integer,String> to String
어디에서'super.onPostExecute (result);'를해야합니까? 나는 그 라인을 넣지 않았고 여전히 작동합니다! –