AsyncTask onPreExecute progressdialog

There is a usual problem with progressdialogs and contexts, it happens to me all the time and there's a section on the android doc for this exact problem. You have probably declared it with a context of "this" when the context should actually be the name of your Java class followed by ".this".

dialog = ProgressDialog.show(Example.this, "",
                "Doing stuff. Please wait...", true);

This is because you want the progressDialog to show in the main class, not in the Async class.

If this doesn't solve it, you'll need to post the code.


if ((numResults <= 0)) {
    Toast.makeText(TopNewsActivity.this, "No Result Found.",Toast.LENGTH_LONG).show();
    finish();
}

I believe this is not a good thing to do. Don't finish your activity from the non ui thread. Just return null.