Sometimes i get this crash error in my app
java.lang.RuntimeException: An error occured while executing doInBackground()
This is the full l
You're showing a Toast
in loadFeed
which is called in the doInBackground
part of your AsyncTask
. You shouldn't access the UI from there.
I think In this code Toast
make problem for you,
catch (Throwable t){
Log.e("OSFP.News",t.getMessage(),t);
Toast.makeText(nea.this, "Χρειάζεστε σύνδεση στο internet",
Toast.LENGTH_SHORT).show();
finish();
}
Because you are trying to do UI operation
from worker thread of AsyncTask
this will never allowed..
UPDATE: If you want to update something from the doInBackGround()
of AsyncTask
use publishProgress(Progress...)
and onProgressUpdate(Progress...)
.
This is probably because you're trying to display something on doInBackground(). doInBackground runs in a worker thread which cannot do any UI work (including showing Toasts, which is what you're doing). Instead, all UI work should be done on onPostExecute().
You can't do any GUI work on a background thread. Instead you should post a Runnable to a handler created in the GUI thread to make your Toast execute on the correct thread.
EDIT: Since the homework tag was removed, I'll give an outline how to do it;
For a complete example, see this article.