简体   繁体   中英

Android - Listening for incoming TCP/Socket messages in background

I am trying to write a little application which sends TCP messages (with a PrintWriter) to a JAVA Server running on PC. Now the Client should listen in background for incoming messages from the Server. How can I listen for incoming messages an update the GUI with the message from background-task?

You'll want to spin up a background thread for this. Probably the easiest way to go is to use an AsyncTask and then use onPostExecute, or publishProgress, to safely display your message in the UI.

Check out the Android docs on threads .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM