07.01.2013 Views

David Defour - Université de Perpignan

David Defour - Université de Perpignan

David Defour - Université de Perpignan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

Main Activity, Continued<br />

(NistTimeActivity.java)<br />

556<br />

jeudi 26 janvier 12<br />

public void showTime(View clickedButton) {<br />

try {<br />

Socket socket = new Socket(mHost, mPort);<br />

BufferedRea<strong>de</strong>r in = SocketUtils.getRea<strong>de</strong>r(socket);<br />

in.readLine(); // Ignore leading blank line<br />

String timeResult = in.readLine();<br />

mResultDisplay.setText(timeResult);<br />

socket.close();<br />

} catch (UnknownHostException uhe) {<br />

mResultDisplay.setText("Unknown host: " + mHost);<br />

uhe.printStackTrace(); // View this in DDMS window<br />

} catch (IOException ioe) {<br />

mResultDisplay.setText("IOException: " + ioe);<br />

ioe.printStackTrace(); // View this in DDMS window<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!