今天尝试写登陆代码
BmobQuery<Bean> b = new BmobQuery<>(); b.addWhereEqualTo("Phone",phone.getText().toString()); b.findObjects(new FindListener<Bean>() { @Override public void done(List<Bean> list, BmobException e) { if (e == null) { if(list.size()>0){ if (password.getText().toString().equals(list.get(0).Password)){ if (agreement.isChecked()&&list.get(0).State.equals("T")) { EMClient.getInstance().login(list.get(0).Phone,list.get(0).Password,new EMCallBack() {//回调 @Override public void onSuccess() { EMClient.getInstance().groupManager().loadAllGroups(); EMClient.getInstance().chatManager().loadAllConversations(); Log.d("main", "登录成功!"); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { Log.d("main", "登录失败!"); } }); Intent intent = new Intent(Login.this, Friend.class); intent.putExtra("id", list.get(0).getObjectId()); intent.putExtra("phone", phone.getText().toString()); Toast.makeText(Login.this,"登录成功!",Toast.LENGTH_SHORT).show(); startActivity(intent); finish(); } } } }else Toast.makeText(Login.this,e.getMessage(), Toast.LENGTH_SHORT).show(); } });