JSON AsyncTask refactoring to improve quality?
Don't open a resource in one place and close it in another. Keep the opening and closing of a resource localized to the same function (if you open it, you close it). This makes it easier to spot potential resource leaks.

For example, an InputStream is being opened in doInBackground(), but it is being closed in readStream(). Since doInBackground() opened the resource, it should be responsible for closing it.



HttpURLConnection con = (HttpURLConnection)url.openConnection();


You are not using anything specific to HttpURLConnection, so there is no reason to cast it. This works just fine:

URLConnection con = url.openConnection();




try {
    ...
} catch (Exception e) {
    e.printStackTrace();
}


Don't ignore exceptions. Either let them continue up to the caller, or handle them appropriately. The readStream() function is a good example of where the exception should continue to the caller. Declare it as throwing IOException and remove the exception handling:

private String readStream(InputStream in) throws IOException {
    String content = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String line = null;
    while ((line = reader.readLine()) != null) {
        content += line;
    }
    return content;
}




JSONObject jObject = new JSONObject(jArray.get(i).toString());


This can be simplified to this:

JSONObject jObject = jArray.getJSONObject(i);




Declare variables closer to there they are used. For example, in onPostExecute(): i, strValue and arrCategories are all declared at the top of the function, but are only ever used inside the try block.

protected void onPostExecute(String strResult) {
    TextView txtDebug = (TextView)findViewById(R.id.txtdebug);
    try {
        JSONArray jArray = new JSONArray(strResult);
        String[] arrCategories = new String[jArray.length()];
        for (int i = 0; i &lt; jArray.length(); i++) {
            JSONObject jObject = jArray.getJSONObject(i);
            arrCategories[i] = jObject.getString("name");
        }
        txtDebug.setText(Arrays.toString(arrCategories));
    } catch (JSONException e) {
        e.printStackTrace();
        txtDebug.append("Error in categories json file \n");
        txtDebug.append(String.valueOf(e));
    }
}




I would also like to see onPostExecute() broken down further. It is currently doing two things: parsing the JSON array and updating the UI. Move those into their own functions.



I am not a big fan of the comments in this code. I do not believe they add any value, and are only a distraction while reading.