I\'m getting an error in my logcat stating:
java.net.UnknownHostException: apps.example.com
09-13 14:57:28.970: W/System.err(3823): android.view.ViewRoot$Cal
You are trying to update an UI element from a Thread
that is not the UI Thread
.
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
Looks like you are trying to update the UI
on a background Thread
like in doInBackground()
of your AsyncTask
. You can't do this. You need to update the UI
on a UI Thread
. Use any of the other AsyncTask
methods to do this such as
onPreExecute()
onProgressUpdate()
or
onPostExecute()
AsyncTask Docs
you may also want to see
Processes and Threads
In
protected InputStream doInBackground(String... params)
You have
stream = getQueryResults(Base_URL);
Then In getQueryResults
you have
catch (Exception e) {
Log.e(LOG_TAG, e.toString());
tryagain();
}
The In tryagain
you have
public void tryagain() {
setContentView(R.layout.tryagain);
You cannot update/access ui from a background thread. That is why you are getting that exception.
Also you should re consider your design. If you have setContentView
more than once in the same activity re consider your design.
Also instead of mutiple try blocks have one try block and multiple catch blocks.
Not sure what you want but you are calling publishProgress
more than once.