まず第一に、私はこれにかなり慣れていないので、サーバー/クライアントソケットが動作しており、サーバーはデータを送受信していますが、現時点ではクライアントはtry/catchブロックでデータを送信しているだけで、別のメソッドを書く必要があります受信データをキャッチするだけですか?そして、元のtry/ctach*の外に保つために
どんな助けでも素晴らしいでしょう
public void onClick(View v)
{
setMyIp(ipaddress.getText().toString());
// myComs.sending_data(getMyIp() , "Got connected");
try
{
InetAddress inet = InetAddress.getByName(getMyIp());
Socket s = new Socket(inet, 2000);
OutputStream o = s.getOutputStream();
PrintWriter p = new PrintWriter(o);
InputStream in = s.getInputStream();
p.println("You are connected");
p.flush();
readContacts();
//inboxConversations();
//outboxConversations();
readSms();
}
catch (UnknownHostException e)
{
ipaddress.setText("Unknown host");
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
これは私のコードであり、ボタンの外側に別のリスナーを作成する必要があります。
ありがとうございました