这就是我要做的
UploadCompleteListener 是一个充当回调的自定义接口(interface)。
@Overrider
public Result doWork() {
mUpLoadDataService.uploadInspectionData(new UpLoadDataService.UploadCompleteListener() {
@Override
public void uploadComplete() {
return Result.success(); //this is what I want to do
}
@Override
public void uploadFailed(String reason) {
return Result.failure(); //this is what I want to do
}
});
return null;
}
可能吗?
如果可能的话,请尽快回复。如果您需要,我可以提供更多详细信息。
最佳答案
** 这对我有用 **
@NonNull
@Override
public Result doWork() {
final Result[] result = new Result[1];
mUpLoadDataService.uploadInspectionData(new UpLoadDataService.UploadCompleteListener() {
@Override
public void uploadComplete() {
result[0] = Result.success(); //this is what I want to do
}
@Override
public void uploadFailed(String reason) {
result[0] = Result.failure(); //this is what I want to do
}
});
return result[0];
}
关于java - 如何从回调函数返回某些内容给父函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58393484/