What Is The Error? New To Android Programming
I am trying to implement a server client program to send message in Android.Can you please say me what are the errors in my code and how to rectify them? The server is running fine
Solution 1:
That is why I am using the AsyncTask thread.But even then I get the NetworkOnMainThread Exception.
Actually you are not.You need to call execute() instead of calling doInBackground() directly, otherwise you're not using any of the plumbing provided by the AsyncTask, and you're just calling the method directly in the UI thread.
Solution 2:
you are doing textIn.setText(dataInputStream.readUTF());
in doInBackground() method. While, doInBackground should contain only operations which are not part of event thread, so, use
publishProgress(param); to achive this.
Post a Comment for "What Is The Error? New To Android Programming"