Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error parsing data org.json.JSONException

    I trying to load the data based on user selected. But it keep the shows the same data even I choose different matrix_id. Did I misplace try/catch ?
    Please help me.

    thanks


    /**
    * Getting subject details in background thread
    * */
    protected JSONObject doInBackground(String... params) {

    JSONObject json = null;

    try {
    List<NameValuePair> param = new ArrayList<NameValuePair>();
    param.add(new BasicNameValuePair("matrix_id", matrix_id));
    json = jsonParser.makeHttpRequest(url_subject_details, "GET", param);
    }

    catch(Exception e)
    {
    e.printStackTrace();
    }
    return json;

    }




    /**
    * After completing background task Dismiss the progress dialog
    * **/
    protected void onPostExecute(JSONObject json) {
    super.onPostExecute(json);

    // check your log for json response
    Log.d("Single Subject Details", json.toString());

    try{

    // json success tag
    int success = json.getInt(TAG_SUCCESS);

    if (success == 1) {

    // successfully received subject details
    JSONArray subjectObj = json.getJSONArray(TAG_STUDENT); // JSON Array

    // get first subject object from JSON Array
    JSONObject subject = subjectObj.getJSONObject(0);

    // subject with this matrix_id found
    // Edit Text
    txtName = (EditText) findViewById(R.id.inputName);
    txtEmail = (EditText) findViewById(R.id.inputEmail);

    // display subject data in EditText
    txtName.setText(subject.getString(TAG_NAME));
    txtEmail.setText(subject.getString(TAG_EMAIL));
    }
    else {}
    // dismiss the dialog once got all details

    }
    catch (Exception e) {
    e.printStackTrace();
    }
    pDialog.dismiss();
    }

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Java != JavaScript
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •