I have created a thread on and called that on button click:
btnUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Thread(new ClientThread()).start();
}
});
This is my main thread:
class ClientThread implements Runnable {
@Override
public void run() {
try {
InetAddress serverAddr = InetAddress.getByName(SERVER_IP);
socket = new Socket(serverAddr, SERVERPORT);
} catch (UnknownHostException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
I need to stop the thread after actions of button click. How will I do it? I have tried Boolean, interrupt methods but not working. How can I stop it? Please help me.