我一直在使用Callable
,但现在我需要该函数在call
方法中使用参数。我知道这不是能力,call
所以我该怎么做?
我目前拥有的(错误):
AsyncTask async = new MyAsyncTask();
async.finished(new Callable(param) {
// the function called during async.onPostExecute;
doSomething(param);
});
async.execute(url);
我的异步任务:
...
@Override
protected void onPostExecute(JSONObject result) {
//super.onPostExecute(result);
if(result != null) {
try {
this._finished.call(result); // not valid because call accepts no params
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void finished(Callable<Void> func) {
this._finished = func;
}
...