Was it even possible to have an AsyncTask on Android that throws things? If I do not use the @Override method, it will not be called. If I add throws at the end, there will be compiler errors. For example, I want to do something like:
class testThrows extends AsyncTask<String,Void,JSONObject> {
@Override
protected JSONTokener doInBackground(<String>... arguments) throws JSONException {
String jsonString = arguments[0];
JSONTokener json = new JSONTokener(jsonString);
JSONObject object = json.getJSONObject("test");
return object;
}
}
json.getJSONObject throws a JSONException. Is there any way to do this?
source
share