检测到android用户空间异常!显示java.lang.NullPointerException

时间:2018-04-11 07:53:23

标签: android exception post nullpointerexception

我在这里遇到这个问题: 创建ResultadoObject,它将转到catch。

str =“”,responseBody = {byte [0] @ 5870},而statusCode:200

我想我收到一个空的回复,请问有什么帮助吗?谢谢

client.post(url, requestParams, new AsyncHttpResponseHandler(){
  @Override
  public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
      System.out.println("onSuccess");
      String str = null;
      try {
          str = new String(responseBody, "UTF-8");
      }
      catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      }
      if (str != null)
      {
          ResultadoObject resultado = null;
          try {
             resultado = new ResultadoObject(new JSONObject(str));
          } catch (JSONException e) {
             e.printStackTrace();
          }
          if (resultado.Flag != 0 && resultado.IDMantenimiento != 0)
          {
             loading = false;
             progressDialog.dismiss();
             cambios = true;
             getMantenimiento(resultado.IDMantenimiento);
          }

“检测到用户空间异常!

  

java.lang.NullPointerException:尝试从空对象引用上的字段'int com.model.ResultadoObject.Flag'读取                                                                    at com.activities.MantenimientoEditarActivity $ 7.onSuccess(MantenimientoEditarActivity.java:791)                                                                    在com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:351)                                                                    在com.loopj.android.http.AsyncHttpResponseHandler $ ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510)                                                                    在android.os.Handler.dispatchMessage(Handler.java:105)                                                                    在android.os.Looper.loop(Looper.java:164)                                                                    在android.app.ActivityThread.main(ActivityThread.java:6541)                                                                    at java.lang.reflect.Method.invoke(Native Method)                                                                    在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)                                                                    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)“

0 个答案:

没有答案