我两次使用jsonParser。 在第二种方法中使用它时出现错误。 有人可以告诉我为什么会出现此错误吗?

这是我使用它的第一种方法

  protected Void doInBackground(Void... arg0) {

                ServiceHandler jsonParser = new ServiceHandler();
                //String json = jsonParser.makeServiceCall(URL_TIME, ServiceHandler.GET);
               /*DatePickerDialog.OnDateSetListener datePickerListener1 = new DatePickerDialog.OnDateSetListener() {
                    public void onDateSet(DatePicker view, int selectedYear,
                            int selectedMonth, int selectedDay) {
                        et.setText(selectedYear + "/" + (selectedMonth + 1) + "/"
                                + selectedDay);

                     datestr = et.getText().toString();

                    }
                };*/
                Log.e("Response: ", "> JSON RESPONSE " + datestr );
                String json = jsonParser.makeServiceCall("http://10.0.2.2/trackingsystem/get_time3.php?datestr=" + datestr ,ServiceHandler.GET);
                Log.e("Response: ", "> " + json );

                if (json != null) {
                    try {

                        JSONObject jsonObj = new JSONObject(json);
                        if (jsonObj != null) {
                            JSONArray timeA = jsonObj.getJSONArray("daydate");                        
                             for (int i = 0; i < timeA.length(); i++) {
                                JSONObject timeObj = (JSONObject) timeA.get(i);
                                TTime tobj = new TTime(timeObj.getString("time"));
                                TimeList.add(tobj);
                            }
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                } else {
                    Log.e("JSON Data", "DID NOT RECEIVE ANY DATA FROM THE SERVER!");
                }

                return null;
            }

这是我正在使用的第二种方法

 private class PlotMap extends AsyncTask<Void, Void, Void>
       {

         @Override
            protected Void doInBackground(Void... arg0) {

                 //Log.e("Response: ", "> JSON RESPONSE " + datestr + seltime);
                String json1 = jsonParser.makeServiceCall("http://10.0.2.2/trackingsystem/latlng.php?datestr=" + datestr + "&time=" + seltime ,ServiceHandler.GET);
                Log.e("Response: ", "> " + json1 );

                if (json1 != null) {
                    try {
                            JSONObject jsonObj = new JSONObject(json1);
                            JSONArray jArray1 = jsonObj.getJSONArray(json1);
                            //JSONArray jArray1 = new JSONArray(json1);
                            for (int i = 0; i < jArray1.length(); i++) {
                            JSONObject json_data = jArray1.getJSONObject(i);
                            JSONObject json_data1 = jArray1.getJSONObject(i);
                            latString =json_data.getString("lat") + "\n";
                            lonString =json_data1.getString("lon") + "\n";
                            System.out.println(latString);
                            System.out.println(lonString);
                            }           

                        Intent intent = new Intent(getApplicationContext(), Map.class);
                        Bundle extras = new Bundle();
                        extras.putString("LATITUDE", latString);
                        extras.putString("LONGITUDE", lonString);
                        intent.putExtras(extras);
                        startActivity(intent);



                    }catch (JSONException e) {
                            e.printStackTrace();
                        }   


            } else {
                Log.e("JSON Data", "DID NOT RECEIVE ANY DATA FROM THE SERVER!");
            }

            return null;
          }
       }

  ask by user3542601 translate from so

本文未有回复,本站智能推荐: