改造中如何处理204个响应

时间:2019-05-07 10:13:16

标签: android

如何在翻新中处理204个响应。.
我想显示接收到的响应中的消息,但由于它使我进入公共void onFailure()方法,因此无法获得消息。

从API获取此响应(在标头部分中,我也得到204)

{
    "Response": {
        "Status": false,
        "Code": "204",
        "Msg": "You can not have more than one Primary Language"
    }
}**


    Call<ResponseAddModel> call = apiInterface.UserApiCallHare(auth_key, Lempid, TLS_locid, TLS_cid, String.valueOf(0), String.valueOf(1), String.valueOf(LangId), String.valueOf(readNo), String.valueOf(writeNo), String.valueOf(speakNo), String.valueOf(primaryLang));
                call.enqueue(new Callback<ResponseAddModel>() {
                    @Override
                    public void onResponse(Call<ResponseAddModel> call, Response<ResponseAddModel> response) {
                        pDialog.dismiss();
                        if (response.body() != null && response.isSuccessful()) {

                            if (response.code() == 200) {
                                Log.e(getClass().getName(), "ok==========");


                           } else if (response.code() == 204) {
                                Log.e(getClass().getName(), "204==========");


                            }

                        }
                    }

                    @Override
                    public void onFailure(Call<ResponseAddModel> call, Throwable t) {
                        pDialog.dismiss();
                        Log.e(getClass().getName(), "error==========" + t.getLocalizedMessage());

                         Toast.makeText(getActivity(), "Please check your Internet Connection", Toast.LENGTH_SHORT).show();
                    }

enter image description here

0 个答案:

没有答案