Android 安卓&;Azure移动服务查询:如何在查询完成之前暂停代码执行

Android 安卓&;Azure移动服务查询:如何在查询完成之前暂停代码执行,android,azure-mobile-services,Android,Azure Mobile Services,我需要知道如何停止代码执行,直到我的移动服务查询完成。我得到一个空指针异常,因为代码试图在查询完成之前访问查询数据 ---Code--- mEmployeeTable.execute(new TableQueryCallback<Employee>() { //get employees ... }); //In this activity i attempt to use the info loaded from the query above //however since

我需要知道如何停止代码执行,直到我的移动服务查询完成。我得到一个空指针异常,因为代码试图在查询完成之前访问查询数据

---Code---
mEmployeeTable.execute(new TableQueryCallback<Employee>() {
 //get employees
 ...
});

//In this activity i attempt to use the info loaded from the query above
//however since the query has not completed i get null pointer exception
startActivity(intent);
---代码---
mEmployeeTable.execute(新的TableQueryCallback(){
//雇佣员工
...
});
//在这个活动中,我尝试使用从上面的查询中加载的信息
//然而,由于查询尚未完成,我得到空指针异常
星触觉(意向);

您只需要在收到回调时启动活动,类似于下面的代码:

mEmployeeTable.execute(new TableQueryCallback<Employee>() {
  @Override
  public void onCompleted(List<Employee> employees, int count, Exception exception, ServiceFilterResponse response) {
    if (exception != null) {
      // error happened during query, deal with it appropriately
    } else {
      // store the loaded employees somewhere
      startActivity(intent);
    }
  }
});
mEmployeeTable.execute(新的TableQueryCallback(){
@凌驾
未完成公共无效(列出员工、整数计数、异常、ServiceFilterResponse响应){
if(异常!=null){
//查询时出错,请妥善处理
}否则{
//将装载的员工存放在某个地方
星触觉(意向);
}
}
});

假设这是一个web请求,您不能按要求执行,如果您可以发布一些代码,我们可以帮助您查看设计中的错误。我刚刚添加了代码。谢谢你,因为其他原因,我试着用这种方式来做,但我想我可以通过改变其他代码行来实现。谢谢