【发布时间】:2013-04-14 23:17:24
【问题描述】:
我正在尝试从函数的嵌套类中返回一个变量,如下所示:
public int getPlan(int planID) {
int planId;
TableOperationCallback<Plans> callback = new TableOperationCallback<Plans>() {
public void onCompleted(Plans plan, Exception exception,ServiceFilterResponse response) {
if(exception == null){
int planId = (int) db.addPlan(plan); //Want to return this value
} else {
Log.e(exception.getMessage(), "ERROR");
}
}
};
mPlanTable.lookUp(planID, callback);
return planId;
}
此方法与 Azure Android SDK 相关联,并且 mPlanTable.lookUp() 被异步调用。因此,planId 有时会在上面的代码中返回 null。
返回实际值的最佳方法是什么?
【问题讨论】:
标签: java android azure asynchronous