Asnchronous task not working in Android 3.0 - 4.0
<p>I am working in the project which is parsing the values data and displaying using xml parsing.</p>

<p>It was working fine in android version upto 2.3 but not working upto 4.0.</p>

<p>I found, In asynchronous task onPreExeucte method is working well but when the process reaches the doInBackground method it will not working.And showing null exception line number 251.</p>

<p>Here is my code, help me to solve this problem.</p>

<pre><code>public class AsynTaskScoreboard extends AsyncTask&lt;Void, Void, Void&gt; {

    private ProgressDialog dialog = ProgressDialog.show(getParent(), "Retrieving data ", " Loading. Please wait ... ", true);

    // can use UI thread here
    protected void onPreExecute() {
        this.dialog.setMessage("Loading...");
        this.dialog.setCancelable(false);
        this.dialog.show();
    }

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

        try {
            URL xpto = new URL(strMainUrl + "score.php?UserId=" + EventListActivity.UserID);

            Log.e("Total urlScore board", "scr bord full url " + xpto);
            HttpURLConnection conn;

            conn = (HttpURLConnection) xpto.openConnection();
            conn.setDoInput(true);

            conn.connect();
            InputStream is = conn.getInputStream();

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

            try {

                DocumentBuilder db = dbf.newDocumentBuilder();
                Document doc = db.parse(is);
                doc.getDocumentElement().normalize();
                NodeList nodeList;

                nodeList = doc.getElementsByTagName("TotalPoints");
                Node node1 = nodeList.item(0);
                Element fstElmnt1 = (Element) node1;
                NodeList scoreList1 = fstElmnt1.getElementsByTagName("TotalPoints");
                Element scoreElement1 = (Element) scoreList1.item(0);
                scoreList1 = scoreElement1.getChildNodes();
                strTotalPoints = ((Node) scoreList1.item(0)).getNodeValue();

                Log.d("SetText", "strTotalPoints " + strTotalPoints);

                nodeList = doc.getElementsByTagName("ChallengesPlayed");
                node1 = nodeList.item(0);
                fstElmnt1 = (Element) node1;
                scoreList1 = fstElmnt1.getElementsByTagName("ChallengesPlayed");
                scoreElement1 = (Element) scoreList1.item(0);
                scoreList1 = scoreElement1.getChildNodes();
                strChallengesPoint = ((Node) scoreList1.item(0)).getNodeValue();

                Log.d("SetText", "strChallengesPoint " + strChallengesPoint);

                android.os.Message msg = Message.obtain();
                msg.what = 11;
                handler.sendMessage(msg);

                /**
                 * Check whether it is my points or high score
                 */
                switch (flagMypointsOrHighScore) {
                case 0:
                    nodeList = doc.getElementsByTagName("UserScore");

                    // Define Array based on nodelist

                    arrLength = nodeList.getLength();
                    strGameid = new String[arrLength];
                    strGameNameArr = new String[arrLength];
                    strGameLocationArr = new String[arrLength];
                    strGameDate = new String[arrLength];

                    Log.d("SetText", "arrLength " + arrLength);
                    Log.d("SetText", "strGameid " + strGameid);
                    Log.d("SetText", "strGameNameArr " + strGameNameArr);
                    Log.d("SetText", "strGameLocationArr " + strGameLocationArr);
                    Log.d("SetText", "strGameDate " + strGameDate);

                    String[] strXMLTag = { "GameId", "GameName", "Location", "Date" };
                    for (int i = 0; i &lt; arrLength; i++) {

                        Node node = nodeList.item(i);
                        Element fstElmnt = (Element) node;

                        for (int j = 0; j &lt; strXMLTag.length; j++) {
                            NodeList scoreList = fstElmnt.getElementsByTagName(strXMLTag[j]);
                            Element scoreElement = (Element) scoreList.item(0);
                            scoreList = scoreElement.getChildNodes();
                            switch (j) {
                            case 0:
                                strGameid[i] = ((Node) scoreList.item(0)).getNodeValue();
                                break;

                            case 1:
                                strGameNameArr[i] = ((Node) scoreList.item(0)).getNodeValue();

                                break;
                            case 2:
                                strGameLocationArr[i] = ((Node) scoreList.item(0)).getNodeValue();
                                // location =
                                // strGameLocationArr[i].toString().trim();
                                break;
                            case 3:
                                strGameDate[i] = ((Node) scoreList.item(0)).getNodeValue();

                                break;
                            }

                        }

                    }// End of for loop
                        // Your rank

                    break;

                case 1:// Top rank 5

                    nodeList = doc.getElementsByTagName("Top5Rank");

                    // Define Array based on nodelist

                    arrLength = nodeList.getLength();
                    strGameNameArr = new String[arrLength];
                    strGameLocationArr = new String[arrLength];
                    strGameDate = new String[arrLength];
                    for (int i = 0; i &lt; arrLength; i++) {

                        Node node = nodeList.item(i);
                        Element fstElmnt = (Element) node;

                        NodeList rankList = fstElmnt.getElementsByTagName("Person");
                        //
                        int rankListLength = rankList.getLength();

                        if (strPersonNameArr == null) {
                            strPersonNameArr = new String[rankListLength];
                            strPersonRankArr = new String[rankListLength];
                            strPersoonPointsArr = new String[rankListLength];
                        }
                        for (int j = 0; j &lt; rankListLength; j++) {
                            rankList = fstElmnt.getElementsByTagName("Person");
                            Element rankElement = (Element) rankList.item(j);
                            rankList = rankElement.getChildNodes();
                            strPersonNameArr[j] = rankElement.getAttribute("Name");
                            strPersonRankArr[j] = rankElement.getAttribute("Rank");
                            strPersoonPointsArr[j] = rankElement.getAttribute("Points");
                        }

                    }// End of for loop

                    // // Your rank
                    //
                    // nodeList = doc.getElementsByTagName("YourRank");
                    //
                    // // Define Array based on nodelist
                    //
                    // for (int i = 0; i &lt; arrLength; i++) {
                    // //
                    // Node node = nodeList.item(i);
                    // Element fstElmnt = (Element) node;
                    //
                    // NodeList rankList = fstElmnt
                    // .getElementsByTagName("Person");
                    // Element rankElement = (Element) rankList.item(0);
                    // rankList = rankElement.getChildNodes();
                    // strPersonName = rankElement.getAttribute("Name");
                    // strRank = rankElement.getAttribute("Rank");
                    // strPoint = rankElement.getAttribute("Points");
                    //
                    // }// End of for loop
                    break;

                }// End of switch
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }// try below db 2try

        } catch (Exception e) {
            // TODO Auto-generated catch block

            if (e.toString().equalsIgnoreCase("java.net.SocketException: Network unreachable")) {
                android.os.Message msg = android.os.Message.obtain();
                msg.what = 0;
                handler.sendMessage(msg);
            }
            e.printStackTrace();
        }

        return null;
    }// End of do in background method

    // do the stuff after the heavy task

    protected void onPostExecute(Void result) {
        android.os.Message msg = Message.obtain();
        switch (flagMypointsOrHighScore) {
        case 0:
            listViewMyPoints.setAdapter(new JR_LB_ListAdapter(ScoreboardActivity.this));
            break;
        case 1:
            listViewHighScores.setAdapter(new JR_LB_ListAdapter_HighScores(ScoreboardActivity.this));
            // Set textview value in the
            msg.what = 10;
            handler.sendMessage(msg);
            break;
        default:

        }

        if (this.dialog.isShowing()) {
            this.dialog.dismiss();
        }
    }// End of on post execute method

    @Override
    protected void onProgressUpdate(Void... values) {
        // TODO Auto-generated method stub
        Totalpoint.setText(strTotalPoints);
        challengeplay.setText(strChallengesPoint);
        txtViewRank.setText(strRank);
        txtViewPoint.setText(strPoint);
        txtViewPersonName.setText(strPersonName);

    }

}// End of Asynchronous task class
</code></pre>
