亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么登錄請求時 密碼或者賬號錯誤Toast不彈。我寫了Toast(代碼如下) 急 急 急

為什么登錄請求時 密碼或者賬號錯誤Toast不彈。我寫了Toast(代碼如下) 急 急 急

lay_hu 2017-10-31 09:38:46
??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";
查看完整描述

2 回答

?
qq_我們咫尺之間_0

TA貢獻5條經驗 獲得超1個贊

你能確定的回調被調用了么

然后才是toast的問題

吐槽下? static final 后面的變量全部要大寫

查看完整回答
反對 回復 2017-10-31
  • lay_hu
    lay_hu
    已經解決了。忘寫一個異常處理了。那個大寫的我也是趕項目,沒那么多講究了
  • 2 回答
  • 0 關注
  • 2138 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號