This is my class that extends AsyncTask
public class JSONFunctions extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... urls) {
String line = "";
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://appDev.milasevicius.com/server/homeresults.php");
try {
HttpResponse response = httpclient.execute(httpget);
if(response != null) {
InputStream inputstream = response.getEntity().getContent();
line = convertStreamToString(inputstream);
} else {
line = "Unable to complete your request";
}
} catch (ClientProtocolException e) {
line = "Caught ClientProtocolException";
} catch (IOException e) {
line = "Caught IOException";
} catch (Exception e) {
line = "Caught Exception";
}
return line;
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(String result) {
}
}
And this is my call:
String output = new JSONFunctions().execute().get();
But compilator says that
error: unreported exception InterruptedException; must be caught or declared to be thrown
sorry for my noobish question, but how to fix that? And am I doing right call to get result?