No output after asyncTask completes in Android app
<p>The output for this activity produces a blank screen with titlebar. What am I doing wrong here? Removing <code>asyncTask</code> method gives the output perfectly, but with time delay. Please help me out.</p>

<pre><code>public class viewstoryActivity extends Activity {
    public Context context;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);
        context = this;
        DownloadTask task = new DownloadTask();
        task.execute();
    }

    public void test() {
        try {
            LinearLayout layout[];
            LinearLayout layout2[];
            LinearLayout layout3[];
            TextView name[];
            TextView desc[];
            TextView viewCount[];
            ImageView website[];
            ImageView star[];
            TextView category[];
            URL url = new URL("http://gdata.youtube.com/feeds/api/videos?start-index=1&amp;max-results=25&amp;vq=itsaperfectstory&amp;orderby=relevance");
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(new InputSource(url.openStream()));
            // doc.getDocumentElement().normalize();
            NodeList nodeList = doc.getElementsByTagName("entry");
            layout = new LinearLayout[nodeList.getLength()];
            layout2 = new LinearLayout[nodeList.getLength()];
            layout3 = new LinearLayout[nodeList.getLength()];
            name = new TextView[nodeList.getLength()];
            desc = new TextView[nodeList.getLength()];
            viewCount = new TextView[nodeList.getLength()];
            website = new ImageView[nodeList.getLength()];
            star = new ImageView[nodeList.getLength()];
            category = new TextView[nodeList.getLength()];
            for (int i = 0; i &lt; nodeList.getLength(); i++) {
                Node node = nodeList.item(i);
                layout[i] = new LinearLayout(context);
                layout[i].setOrientation(LinearLayout.HORIZONTAL);
                layout[i].setBackgroundResource(R.anim.bg);
                layout[i].setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 150));
                layout2[i] = new LinearLayout(context);
                layout2[i].setOrientation(LinearLayout.VERTICAL);
                layout2[i].setLayoutParams(new LayoutParams(400, 150));
                layout3[i] = new LinearLayout(context);
                layout3[i].setOrientation(LinearLayout.VERTICAL);
                layout3[i].setLayoutParams(new LayoutParams(150, 150));
                name[i] = new TextView(context);
                desc[i] = new TextView(context);
                viewCount[i] = new TextView(context);
                website[i] = new ImageView(context);
                star[i] = new ImageView(context);
                category[i] = new TextView(context);
                name[i].setPadding(10, 20, 0, 0);
                name[i].setTextSize(16);
                Element fstElmnt = (Element) node;
                NodeList nameList = fstElmnt.getElementsByTagName("title");
                Element nameElement = (Element) nameList.item(0);
                nameList = nameElement.getChildNodes();
                name[i].setText(((Node) nameList.item(0)).getNodeValue());
                name[i].setLines(1);
                NodeList websiteList = fstElmnt.getElementsByTagName("media:content");
                Element websiteElement = (Element) websiteList.item(0);
                websiteList = websiteElement.getChildNodes();
                final String url1 = websiteElement.getAttribute("url");
                NodeList websiteList1 = fstElmnt.getElementsByTagName("media:thumbnail");
                Element websiteElement1 = (Element) websiteList1.item(0);
                String test = websiteElement1.getAttribute("url");
                NodeList descitem = fstElmnt.getElementsByTagName("content");
                Element descElement = (Element) descitem.item(0);
                nameList = descElement.getChildNodes();
                desc[i].setText(((Node) nameList.item(0)).getNodeValue());
                desc[i].setLines(1);
                desc[i].setTextColor(Color.DKGRAY);
                desc[i].setPadding(10, 8, 0, 0);
                NodeList gditem = fstElmnt.getElementsByTagName("yt:statistics");
                Element gdElement = (Element) gditem.item(0);
                String view1 = gdElement.getAttribute("viewCount");
                viewCount[i].setText(view1 + " views");
                viewCount[i].setPadding(10, 8, 0, 0);
                Bitmap bm = null;
                URL aURL = new URL(test);
                URLConnection conn = aURL.openConnection();
                conn.connect();
                InputStream is = conn.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);
                bm = BitmapFactory.decodeStream(bis);
                bis.close();
                is.close(); // TODO: handle exception
                website[i].setImageBitmap(bm);
                website[i].setPadding(30, 20, 0, 0);
                layout3[i].addView(website[i]);
                layout2[i].addView(name[i]);
                layout2[i].addView(desc[i]);
                layout2[i].addView(viewCount[i]);
                NodeList staringitem = fstElmnt.getElementsByTagName("gd:rating");
                if ((staringitem == null) || (staringitem.getLength() == 0)) {
                    star[i].setImageResource(R.drawable.star0);
                    layout2[i].addView(star[i]);
                } else {
                    Element starElement = (Element) staringitem.item(0);
                    String stars = starElement.getAttribute("average");
                    double d = Double.parseDouble(stars);
                    DecimalFormat decimalFormat = new DecimalFormat("#");
                    stars = decimalFormat.format(d);
                    if (stars.contentEquals("1")) {
                        star[i].setImageResource(R.drawable.star1);
                        layout2[i].addView(star[i]);
                    } else if (stars.contentEquals("2")) {
                        star[i].setImageResource(R.drawable.star2);
                        layout2[i].addView(star[i]);
                    } else if (stars.contentEquals("3")) {
                        star[i].setImageResource(R.drawable.star3);
                        layout2[i].addView(star[i]);
                    } else if (stars.contentEquals("4")) {
                        star[i].setImageResource(R.drawable.star4);
                        layout2[i].addView(star[i]);
                    } else if (stars.contentEquals("5")) {
                        star[i].setImageResource(R.drawable.star5);
                        layout2[i].addView(star[i]);
                    } else if (stars.contentEquals("0")) {
                        star[i].setImageResource(R.drawable.star0);
                        layout2[i].addView(star[i]);
                    }
                }
                layout[i].addView(layout3[i]);
                layout[i].addView(layout2[i]);
                // layout.addView(category[i]);
                // layout[i].addView(img[i]);
                LinearLayout layout1 = (LinearLayout) findViewById(R.id.LinearLayout);
                ((LinearLayout) layout1).addView(layout[i]);
                layout[i].setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        Bundle bundle = new Bundle();
                        bundle.putString("url", url1);
                        Intent intent = new Intent(viewstoryActivity.this, VidActivity.class);
                        intent.putExtras(bundle);
                        startActivityForResult(intent, 0);
                        overridePendingTransition(R.anim.right_slide_out, R.anim.right_slide_out);
                    }
                });
            }
        } catch (Exception e) {
            System.out.println("XML Pasing Excpetion = " + e);
        }
    }

    private class DownloadTask extends AsyncTask&lt;String, Void, String&gt; {
        ProgressDialog progressDialog;

        @Override
        protected void onPreExecute() {
            progressDialog = ProgressDialog.show(viewstoryActivity.this, "Progress Dialog Title Text", "Process Description Text", true);
            // do initialization of required objects objects here
        };

        @Override
        protected String doInBackground(String... urls) {
            test();
            return "";
        };

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            progressDialog.dismiss();
        };
    }
}
</code></pre>
