快捷导航

为什么登录请求时 密码或者账号错误Toast不弹。我写了Toast(代码如下) 急

String id="?loginname="+mUserName.getText().toString()+"&password="+mPassWord.getText().toString();        OkHttpClient mOkHttpClient=new OkHttpClient();        Request mRequest=new Request.Builder().get().url(URL+id).build();        Log.d("jkie",URL+id);        Call mCall=mOkHttpClient.newCall(mRequest);        mCall.enqueue(new Callback() {            @Override            public void onFailure(Request request, IOException e) {//                Toast.makeText(LoginActivity.this,"登录失败,请重试!",Toast.LENGTH_SHORT).show();             Log.d("hjauens",e.getMessage());            }            @Override            public void onResponse(Response response) throws IOException {                final String mResponse=response.body().string();                Log.d("hhaha",mResponse);                runOnUiThread(new Runnable() {                    @Override                    public void run() {                        parset(mResponse);                    }                });            }        });    }    private void parset(String mResponse) {        try {            JSONObject mJSON=new JSONObject(mResponse);            JSONObject mJ=mJSON.getJSONObject("loginUser");             mToken=mJ.optString("id");            Log.d("token",mToken);            App.getApp().setToken(mToken);            String message=mJSON.optString("message");            Log.d("消息",message);//            if (message.equals(Constants.Wrong_account)){//              LoginActivity.this.showLongToast("账号有误");//          }//          if (message.equals(Constants.Account_no_entry)){//              LoginActivity.this.showLongToast("账号禁止登陆");//          }//          if (message.equals(Constants.Abnormal_occurrence)){//              LoginActivity.this. showLongToast("服务器异常");//          }          if (message.equals(Constants.Successful_operation )){              Intent i=new Intent(LoginActivity.this,MainActivity.class);              startActivity(i);              finish();          }//          if (message.equals(Constants.password_incorrect)){//              LoginActivity.this.showLongToast("旧密码不正确");//          }//          if (message.equals(Constants.Already_in_use)){//              LoginActivity.this.showLongToast("用户名已被使用");//          }        } catch (JSONException e) {            e.printStackTrace();        }    }        后台给我了一个返回参数 message 然后根据参数值来判断 登录状况  可是都不弹Toast        //  登录请求返回的参数         //账号或密码有误    public  static  final String Wrong_account="20002";         //账号禁止登陆    public  static  final String Account_no_entry="20003";          //异常发生    public  static  final String Abnormal_occurrence ="20004";         //操作成功    public  static  final String Successful_operation ="20005";       //无访问该模块权限       public  static  final String Jurisdiction="20006";       //旧密码不正确       public  static  final String  password_incorrect="20007";       //找不到对象       public  static  final String  Object_not_found="20008";       //    用户名已被使用       public  static  final String Already_in_use="20009";

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

你能确定的回调被调用了么
然后才是toast的问题
吐槽下 static final 后面的变量全部要大写
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP