public class LianjieActivity extends AppCompatActivity {
EditText editText1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lianjie);
editText1=findViewById(R.id.editText1);
Button button=findViewById(R.id.button); //获取连接按钮
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new SocketThread(editText1.getText().toString()).start();
}
});
}
}public class SocketThread extends Thread{
String IP;
Socket socket;
public SocketThread(String msg){
IP= msg;
}
@Override
public void run() {
try {
socket =new Socket(IP,8086);
} catch (IOException e) {
e.printStackTrace();
}
}
}
EditText editText1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lianjie);
editText1=findViewById(R.id.editText1);
Button button=findViewById(R.id.button); //获取连接按钮
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new SocketThread(editText1.getText().toString()).start();
}
});
}
}public class SocketThread extends Thread{
String IP;
Socket socket;
public SocketThread(String msg){
IP= msg;
}
@Override
public void run() {
try {
socket =new Socket(IP,8086);
} catch (IOException e) {
e.printStackTrace();
}
}
}
解决方案 »
- 布局模式中出现的疑惑的问题
- 安卓service的一个非常奇怪的现象?求解释
- 内存不足10000-byte external allocation too large for this process
- 老白问题,ROM与RAM名词解释,望不吝赐教。
- 怎么从软件上屏蔽掉usb接口
- 生成图片
- .net程序员能转Android开发吗?
- CSDN阅读器(android版)今天发布了!!!
- android 通过程序 如何恢复出厂设置或者wipe手机
- 有没有用户行为分析平台介绍
- Android 如何通过WIFI获取打印机状态
- 求MediaCodec.createInputSurface视频编码dequeueOutputBuffer返回-1问题
难道不是IP加端口就能连接吗