在 GetBitMapFromURL 中创建回调。
public class GetBitMapFromURL extends AsyncTask<Void, Void, Void> {
private GetBitMapFromURLCallback mCallback = null;
public WebService(GetBitMapFromURLCallback callback) {
mCallback = callback;
}
@Override
protected Boolean doInBackground(Void... params) {
// ...
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
if (mCallback != null) {
mCallback.onGetBitMapFromURLComplete(this);
}
}
public interface GetBitMapFromURLCallback {
public void onGetBitMapFromURLComplete(GetBitMapFromURL getBitMapFromUrl);
}
}
public class MyActivity extends Activity implements GetBitMapFromURLCallback {
// ...
public void onGetBitMapFromURLComplete(GetBitMapFromURL getBitMapFromUrl) {
// This code will get called the moment the AsyncTask finishes
}
}
并让您的活动实现此回调和onGetBitMapFromURLComplete()
.