¡@

Home 

2014/10/16 ¤W¤È 08:23:40

android Programming Glossary: senddatatonetwork

Example: Android bi-directional network socket using AsyncTask

http://stackoverflow.com/questions/5135438/example-android-bi-directional-network-socket-using-asynctask

networktask new NetworkTask Create initial instance so SendDataToNetwork doesn't throw an error. private OnClickListener btnStartListener.. Sending Message to AsyncTask. networktask.SendDataToNetwork GET HTTP 1.1 r n r n public class NetworkTask extends AsyncTask.. doInBackground Finished return result public void SendDataToNetwork String cmd You run this from the main thread. try if nsocket.isConnected..

Example: Android bi-directional network socket using AsyncTask

http://stackoverflow.com/questions/5135438/example-android-bi-directional-network-socket-using-asynctask

btnStartListener btnSend.setOnClickListener btnSendListener networktask new NetworkTask Create initial instance so SendDataToNetwork doesn't throw an error. private OnClickListener btnStartListener new OnClickListener public void onClick View v btnStart.setVisibility.. new OnClickListener public void onClick View v textStatus.setText Sending Message to AsyncTask. networktask.SendDataToNetwork GET HTTP 1.1 r n r n public class NetworkTask extends AsyncTask Void byte Boolean Socket nsocket Network Socket InputStream.. catch Exception e e.printStackTrace Log.i AsyncTask doInBackground Finished return result public void SendDataToNetwork String cmd You run this from the main thread. try if nsocket.isConnected Log.i AsyncTask SendDataToNetwork Writing received..