Hi Folks,

I am writing an app that involves Client -> Server -> Client communication (one way traffic). I have my data transmitted from client A to the server, simple to test, just print to console, however, I'm trying to test to see if the data has been sent on to the next client. I have tried a text view, nothing is displaying in this view however, now I don't know if that's because the data hasn't arrived or indeed because I've coded it wrong. I'm not very experienced in android.

I've attached my code below, if anyone can help I would really appreciate it.


public class Parent extends Activity {

    private Socket s;
    private PrintWriter p;
    String location;
    double Platitude, Plongitude;
    double Clatitude, Clongitude;
    double distance;

    public void onCreate(Bundle savedInstanceState)


        Thread rec = new Thread(new Runnable() {

            public void run() {

                // TODO Auto-generated method stub
                try { 

                    s = new Socket("", 1980);

                    InputStream fromServer = s.getInputStream();

                    while (s.isConnected()) {

                        Scanner r = new Scanner(fromServer);

                            location = r.nextLine();

                        TextView myTextview = (TextView) findViewById(R.id.dist);


                } catch (UnknownHostException e) {
                } catch (IOException e) {

sorted this one myself...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.