Hello! In a day, I asked a question...I have a question about json paser

Asked 1 years ago, Updated 1 years ago, 52 views

10-1809:01:31.218 15389-15897/com.oh_biz.oh_works W/System.err: at com.oh_biz.oh_works.View.Tab1$AsyncHttpask.parseResult(Tab1.java:215)
10-18 09:01:31.218 15389-15897/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab1$AsyncHttpTask.doInBackground(Tab1.java:145)
10-18 09:01:31.218 15389-15897/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab1$AsyncHttpTask.doInBackground(Tab1.java:109)
10-18 09:01:31.228 15389-15898/com.oh_biz.oh_works D/Tab2: Tab2[{"id":"1610/17031057", "date":"16/10/12", "model":"SX730C-CT", "modet"", "models"", "t:"Tab2":"{"id":":":":"10"10"10"10"10"10"10"10"10"tb"10"10"10"tb"tb"tb"tb"tb":/13", "model":"SMT-C5010", "model_class":"STB", "qty":"5"",s_team":"IO-Team"",s_tel":"Lee Dong-gyu"center":"Anyang"",status1":"10"16"/14",status:"10"16"d2"14",Status:"10"10"10"16"16"16"d2"16"16"16"16"16"16"16"16"/14"16"16"16"16"16"16"16"16"16"1":"Awaiting Approval"", status2":"5"",sum_stb":"45"",{"id":"16101323","date":"2016/10/13", "model":"SMT-C5010", "model":"SUMT"stb":"4",{"id":"10/13","2016"2016"10/13","20","20"20"20"20","20"20",":""""""""""""20"20"20"""20""""""""el_class":"STB", "qty":"5"",s_team":"IO-Team","s_tel":","s_name":"Lee Dong-kyu":"center":"Anyang","status1":"5","sum_b":":"16"d10/13",{:10"10"10"dtelid":"16"10":"16"16"16":"/13"16"16":"12"12":":"12"12"12"12"12"12"12"12"12"12:"45"}]
10-18 09:01:31.228 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab2$AsyncHttpTask.parseResult(Tab2.java:228)
10-18 09:01:31.228 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab2$AsyncHttpTask.doInBackground(Tab2.java:157)
10-18 09:01:31.228 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab2$AsyncHttpTask.doInBackground(Tab2.java:124)
10-18 09:01:31.238 15389-15898/com.oh_biz.oh_works D/Tab3: Tab3[{"id":"161017031050", "date":"16/10/17", "model":"SMT-C5012", "SMT-center", "Celse":"_t:"Tab3[{"id":":"10"10"10"10":"10"10"10"10"10"10"10"10"10"10"10"10"10"10"10"10"10"10"10"12", "model":"SMT-C5012", "model_class":"STB", "qty":"20"",s_team":"IO-Team":"s_tel":"center":"Anyang"",status1:"sending..."240"status"6"
10-18 09:01:31.238 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab3$AsyncHttpTask.parseResult(Tab3.java:197)
10-18 09:01:31.238 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab3$AsyncHttpTask.doInBackground(Tab3.java:129)
10-18 09:01:31.238 15389-15898/com.oh_biz.oh_works W/System.err:     at com.oh_biz.oh_works.View.Tab3$AsyncHttpTask.doInBackground(Tab3.java:92)

Hello, everyone Thank you for watching every time. I'm asking you because the json value is well received, but it doesn't get sprayed at first when it keeps getting sprayed on the list view. Especially, I get LG phones and other phones well, but I don't get them from certain phones, especially Samsung phones. I've tried 5 and 6 versions I can take all the other 5 and 6 versions! Also, if you use Wi-Fi here, you can't get a phone that doesn't work. If you use hotspot or LTE, it works well. Have you ever experienced this before?Please help me.

@Override
        protected String doInBackground(String... params) {
            result = new StringBuilder();
            urlConnection = null;
            if ((key.equals("1"))) {
                url1 = "http://dbserver.x-y.net/oh-android/json/json_pro_stb1.php?TEAM=" + team;
            } } else if ((key.equals("2"))) {
                url1 = "http://dbserver.x-y.net/oh-android/json/json_pro_cm1.php?TEAM=" + team;
            }
            try {
                URL url = new URL(url1);
                urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.connect();
                InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "EUC-KR"));
                String line;
                String result = "";
                while ((line = reader.readLine()) != null) {
                    result += line;
                }
                parseResult(result);
                // // Close stream
                if (null != in) {
                    in.close();
                }
                return result;
            } } catch (Exception e) {
                e.printStackTrace();
            } } finally {
                assert urlConnection != null;
                urlConnection.disconnect();
            }
            return result.toString();
        }

        @Override
        protected void onPostExecute(String result) {
            // // Download complete. Lets update UI
            asyncDialog.dismiss();
            mListAdapter.setListData(mListData);
            if (key.equals("1")){
                try {
                    stb_total = response.getJSONObject(0).getString("sum_stb");
                } } catch (JSONException e) {
                    e.printStackTrace();
                }
                Log.d("stb_total","total"+stb_total);
                tv_sum.setText ("Total:" + stb_total);
            }
            else if (key.equals("2")){
                try {
                    cm_total = response.getJSONObject(0).getString("sum_cm");
                } } catch (JSONException e) {
                    e.printStackTrace();
                }
                Log.d("cm_total","total"+cm_total);
                tv_sum.setText ("Total:" + cm_total);
            }
            Log.d("Adapter", TAG + mListAdapter);
        }

        private void parseResult(String result) {
            try {
                response = new JSONArray(result);
                Log.d("Tab1","Tab1"+result);
                View_item item;
                model = response.getJSONObject(0).getString("model");
                String temp = model;
                if (temp.equals("")){
                }
                else {
                    for (int i = 0; i < response.length(); i++) {
                       item = new View_item(getActivity(), response.getJSONObject(i));
      mListData.add(item);
                    }
                }

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

java json android

2022-09-22 20:44

1 Answers

Looking at the log you posted, AsyncHttpTask.An error occurs inside parseResult(). Isn't this a phenomenon caused by this? If an error occurs, there is a possibility that the onPostExecute() will not deliver complete results, and it will not be possible to properly print out the list view. First of all, it would be better to find the cause of the error and correct it.


2022-09-22 20:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.