0

I'm trying to make a TV based android application that was running on android box, but suddenly when I pull the LAN connection from it so the connection was lost the JSONParser.getJSONObject will crash and the weird one is that it does not throw any exception from crashing. Here is my code for JSON parsing.

public void checkData(String url) {

        try {
            final JSONParser jParser = new JSONParser();
            String result = jParser.getJSONFromUrl(url);

            JSONObject json = (JSONObject) new JSONTokener(result).nextValue();
            JSONObject retObj = json.getJSONObject("error");
            String errorStr = retObj.getString("code");

            errView = (TextView) act.findViewById(R.id.error401msg);
            errView.setText(errorStr);
        } catch (JSONException e) {
            System.out.println("Error401::JSON Error: " + e);
        } catch (RuntimeException err) {
            System.out.println("Error401::Runtime Error: " + err);
        } catch (Exception e) {
            System.out.println("Error401::Exception: " + e);
        }
    }
Looking Forward
  • 3,579
  • 8
  • 45
  • 65
  • If this code is executing on the UI Thread, it may be the Android OS killing your application. Best to use an AsyncTask for network communication – Spidy Feb 17 '14 at 08:57
  • I'm sorry buddy but I can't post a logcat, how I wish I can output the logcat in my android box. The only hint that I have is that it was stopping on the "String result = jParser.getJSONFromUrl(url);" line. – WhySoSerious Feb 17 '14 at 09:05
  • Check your url properly... – Piyush Feb 17 '14 at 09:13
  • The URL is correct sir and I guess that is not the issue because the network connection lost already and the application was crash without throwing an exception. – WhySoSerious Feb 17 '14 at 09:42

0 Answers0