RunTimeException while trying to publishProgress
<p>I am getting the following error:</p>

<pre><code>FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.&lt;init&gt;(Handler.java:121)
at android.app.Activity.&lt;init&gt;(Activity.java:735)
at com.dict.SearchDict.&lt;init&gt;(SearchDict.java:42)
at com.dict.XMLParser.&lt;init&gt;(XMLParser.java:23)
at com.dict.InternetDictProvider.searchWord(InternetDictProvider.java:21)
at com.dict.SearchDict$SearchOnline.doInBackground(SearchDict.java:77)
at com.dict.SearchDict$SearchOnline.doInBackground(SearchDict.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
</code></pre>

<p>while trying to call <strong>onProgressUpdate()</strong> from methods of classes other than the class in which I have my AsyncTask i.e. my main activity. From my main activity I execute doInBackground() (i.e. calling the execute method on the object of AsyncTask, which is obvious) in AsyncTask
which creates objects of other classes and give call to their methods (which access Internet). From those methods (which access Internet) I am trying to give a call to onProgressUpdate() using the object of AsyncTask (which I pass in the method call to other classes which is actually a custom created XML parser by me.), but unfortunately I get the above RunTimeExceptions.</p>

<p>Following is my code:</p>

<pre><code>public class SearchOnline extends AsyncTask&lt;String, String, String&gt;//This class is in my main activity.
{
    @Override
    public String doInBackground(String... query)
    {
        InternetDictProvider idp=new InternetDictProvider();
        return idp.searchWord(query[0], this);
                }
                @Override
    public void onProgressUpdate(String... progress)
    {
        oTextView.append(progress[0]);
    }
       }
 public class InternetDictProvider   //This class is in its own file
 {
  public String searchWord(final String query, SearchDict.SearchOnline so)//so is the AsyncTask object
 {
    String result=null;
    XMLParser parser=new XMLParser();
    try
    {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet("http://ox forddictionaries.com/definition/"+query+"?q="+query);
        HttpResponse httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        String meanings=parser.getResultFromXML(StringUtils.inputStreamToString(httpEntity.getContent()), so);// As the name suggests, it gets Result or more precisely data after parsing XML
        so.onProgressUpdate(meanings);//This is where I try to publish Progress
        if(meanings==null)
            return query;
        result = query + ":" + meanings;
        so.onProgressUpdate(result);//
    }
    catch (UnsupportedEncodingException e)
    {
        Log.e(null, e.getStackTrace().toString(), e);
        return query;
    }
    catch (ClientProtocolException e)
    {
        Log.e(null, e.getStackTrace().toString(), e);
        return query;
    }
    catch (IOException e)
    {
        Log.e(null, e.getStackTrace().toString(), e);
        return query;
    }
    catch(Exception e)
    {
        Log.e(null, e.getStackTrace().toString(), e);
        return query;
    }
    return result;
}
</code></pre>

<p>Please could anyone help me soon as my project submission date is approaching fast. And I am trying to solve this error since approx. 2 days.</p>
