集成bmob云进行查询时出的问题
为什么每次都需要点击两次才能查询成功,System输出的结果是第一次点击的时候不会先执行输出111111的那个,然后才会去执行输出00000的,求解释
按钮监听事件
LoginIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myPhone = username.getText().toString();
pwd = password.getText().toString();
queryObjects();
System.out.println("111111111111111" + myPhone2);
Toast.makeText(getApplicationContext(), myPhone2, Toast.LENGTH_LONG).show();
if (myPhone.equals(myPhone2)) {
if (pwd.equals(pwd2)) {
isLogin = true;
tos.setText("登录成功");
Intent intent = new Intent(LoginActivity.this, InfoActivity.class);
startActivity(intent);
} else {
tos.setText("密码错误");
}
} else {
// Toast.makeText(getApplicationContext(), myPhone2, Toast.LENGTH_LONG).show();
tos.setText("账号错误");
}
}
});
public void queryObjects() {
BmobQuery<UserBean> query = new BmobQuery<UserBean>();
query.addWhereEqualTo("phone", myPhone);
query.setLimit(1);
query.findObjects(new FindListener<UserBean>() {
@Override
public void done(List<UserBean> list, BmobException e) {
if (e == null) {
for (UserBean userBean : list) {
myPhone2 = userBean.getPhone();
pwd2 = userBean.getPassword();
}
// mmm.setText(myPhone2);
// Toast.makeText(getApplicationContext(),myPhone2,Toast.LENGTH_LONG).show();
} else {
Log.i("bmob", "失败:" + e.getMessage() + "," + e.getErrorCode());
}
isGet= true;
System.out.println("000000000000"+myPhone2);
}
});
}
}