-2
   RequestParams params = new RequestParams();

    params.put("mobile", mobile);
    params.put("is_online", "0");
    params.put("name", name);
    params.put("latitude", latitude);
    /*  */

    String GcmToken = FirebaseInstanceId.getInstance().getToken();
    if (GcmToken != null) {
        params.put("gcm_token", GcmToken);
    } else {
        params.put("gcm_token", gcm_token);
    }

    Server.post("user/register/format/json", params, new JsonHttpResponseHandler() {
        @Override
        public void onStart() {
            super.onStart();          
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            super.onSuccess(statusCode, headers, response);
            try {
                if (response.has("status") && response.getString("status").equalsIgnoreCase("success")) {
                    Log.d(TAG, response.toString());
                    sessionManager.setKEY(response.getJSONObject("data").getString("key"));
                    Toast.makeText(RegisterActivity.this, "success", Toast.LENGTH_LONG).show();
                    startActivity(new Intent(RegisterActivity.this, LoginActivity.class));

                    finish();
                } else {

                    Toast.makeText(RegisterActivity.this, response.getString("data"), Toast.LENGTH_LONG).show();

                }
            } catch (JSONException e) {
                Toast.makeText(RegisterActivity.this, getString(R.string.error_occurred), Toast.LENGTH_LONG).show();
            }
        }
        @Override
        public void onFinish() {
            super.onFinish();
        }
    });

当我运行上面的代码时,我收到了这种类型的异常消息。我不知道为什么它会来。但是,我可以在不同的手机上运行相同的代码并且它正在工作。似乎在某些设备中代码工作正常,但在其他设备中失败。

onFailure(int, Header[], String, Throwable) was not overriden, but callback was received
cz.msebera.android.httpclient.client.HttpResponseException: Conflict
    at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:446)
    at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160)
    at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
    at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)

我只有这个 api 调用得到这个异常,应用程序的其余 API 能够顺利调用。

4

1 回答 1

0

最后我得到了问题,无论如何方法名称寄存器是冲突的。我刚刚重命名了方法名称,它工作正常。

于 2019-04-27T13:06:45.367 回答