[英]Android User Login with Retrofit
I am trying to use my own login api via retrofit.我正在尝试通过改造使用我自己的登录 api。 The Problem is, if username and password is correct, nothing happens and a toast with the message doesn't appears.
问题是,如果用户名和密码正确,则不会发生任何事情并且不会出现带有消息的祝酒词。 But if the username and password is wrong, i get a right response and the toast with the correct message appears?
但是,如果用户名和密码错误,我会得到正确的响应并出现带有正确消息的吐司?
public void onResponse(Call call, Response response) {
if(response.isSuccessful()){
ResObj resObj = response.body();
if(resObj.getMessage().equals("true")){
Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(LoginActivity.this, "The username or password is incorrect", Toast.LENGTH_SHORT).show();
}
}
else {
Toast.makeText(LoginActivity.this, "Error! Please try again!", Toast.LENGTH_SHORT).show();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.