本人Notes地址 由于Bmob的文档更新,对原先BmobUser.login方法进行更改
login方式实现过程:
/**
* 向Bmob 提交登陆数据
*/
private void loginInBmob(final String name, String pwd) {
final BmobUser user = new BmobUser();
user.setUsername(name);
user.setPassword(pwd);
user.login(LoginActivity.this, new SaveListener() {
@Override
public void onSuccess() {
Snackbar.make(mLoginFormView, "登陆成功", Snackbar.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra(SplashActivity.SEND_USER_NAME, name);
startActivity(intent);
finish();
}
@Override
public void onFailure(int i, String s) {
showProgress(false);
Snackbar.make(mLoginFormView, s, Snackbar.LENGTH_SHORT).show();
}
});
}
查看产品介绍及类库文档 http://docs.bmob.cn/data/Android/i_doc/doc/index.html
更改login方式如下:
private voidloginInBmob(finalString username,String password) {
finalBmobUser user =newBmobUser();
user.setUsername(username);
user.setPassword(password);
user.login(newSaveListener(){
@Override
public voiddone(BmobUser bmobUser,BmobException e) {
if(e==null){
Snackbar.make(mLOginFormView,"登陆成功",Snackbar.LENGTH_SHORT).show();
Intent intent =newIntent(loginActivity.this,MainActivity.class);
intent.putExtra(ApplicationConfig.SEND_USER_NAME,username);
startActivity(intent);
finish();
}else{
showProgress(false);
Snackbar.make(mLOginFormView,"登陆失败",Snackbar.LENGTH_SHORT).show();
}
}
});
}