Question: We have a java server and a android client, we can only message at a time. When we try to send a continous flow of
We have a java server and a android client, we can only message at a time. When we try to send a continous flow of messages, using a while loop or a for loop, it breaks down.
How can we fix our code to recieve multiple messages continuously? (out of memory error)
Please advise.

ackage com.example.paul.trial4; import android. support.v7.app.AppCopatActivity; import android.os.Bundle; import android.util.Log; import android.widget.EditText; import java.io. Bufferedwriter; import java.io.Dataoutputstream; import java.io.IOException; import java.io. OutputstreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.util.Scanner; public class MainActivity extends AppCompatActivity f private EditText text; DataOutputstream dout; Socket s=null; Override protected void onCreate (Bundle savedInstanceState) super.onCreate (savedInstanceState); setcontentview (R. layout.activity main); text = (EditText) findViewById(R.ia.editText ) ; final String ip"192.168.0.31"; final int port 3331; new Thread)[ verride ublic void un t try text.setText("connecting"); s=new Socket (ip , port ) ; dout- new DataoutputStream(s.getoutputstream )); dout.writeUTF("hey") dout.flush ) dout.close ) s.close ) )catch (IOException e) e.printStackTrace ) text.setText ("couldnt connect") ).start (0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
