Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't change the UI in a non UI thread. The <code>doInBackground()</code> method is invoked in a non-UI worker thread.</p> <p>The <code>onPreExecute()</code> and <code>onPostExecute()</code> are invoked on the UI thread, so you can use those to change the UI.</p> <p>I suggest you do this:</p> <pre><code>private class URLConnect extends AsyncTask&lt;String, Void, String&gt; { private final ProgressDialog dialog = new ProgressDialog(Login.this); // can use UI thread here protected void onPreExecute() { this.dialog.setMessage("Logging in..."); this.dialog.show(); } // automatically done on worker thread (separate from UI thread) protected String doInBackground(final String... args) { try { String username = txtUname.getText().toString(); String password = txtPass.getText().toString(); List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2); nameValuePairs.add(new BasicNameValuePair("username",username)); nameValuePairs.add(new BasicNameValuePair("password",password)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); String str = inputStreamToString(response.getEntity().getContent()).toString(); results = (String) result.getText(); return str; //Here you return the string you want to set } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } protected void onPostExecute(String resultString) { result.setText(resultString); //Here you change the text on the TextView; Intent intent = new Intent(Login.this,Main_screen.class); intent.putExtra("result", results); pic = "http://teachers.usls.edu.ph/student_pics/" + txtUname.getText() + ".jpg"; intent.putExtra("pic",pic); startActivity(intent); } } </code></pre> <p>My changes are complete, you could copy paste it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload