本人Notes地址 由于Bmob的文檔更新,對原先BmobUser.login方法進行更改
login方式實現(xiàn)過程:
/**
* 向Bmob 提交登陸數(shù)據(jù)
*/
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();
}
}
});
}