Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>NetworkOnmainthreadException occurs because your are running network related operation on the main UI Thread. You should be using a <strong>Asynctask</strong> for this.</p> <p>The exception that is thrown when an application attempts to perform a networking operation on its main thread.</p> <p>This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. See the document Designing for Responsiveness.</p> <p><a href="http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html" rel="nofollow">http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html</a></p> <p>You can use a asycntask. <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">http://developer.android.com/reference/android/os/AsyncTask.html</a></p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new TheTask(username,password).execute(); } class TheTask extends AsyncTask&lt;Void,Void,Void&gt; { String username,pwd; public TheTask(String uname, String password) { username=uname; pwd=password; } protected void onPreExecute() { super.onPreExecute(); //display progressdialog. } protected void doInBackground(Void ...params) { //rest web service. do not update ui here boolean somevalue= Auth(username, pwd); return null; } protected void onPostExecute(Void result) { super.onPostExecute(result); //dismiss progressdialog. //update ui } } </code></pre>
    singulars
    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.
 

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