Im developing a desktop app in java that when the app is closed by the frame I have an event call FrameClosing that make a function when user close the windows , the problem is when the app is close by the task manager or when the user turn off the windows and the app is running, i was trying this.
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
System.out.println("app was stoped");
}
});
but it's only works if app is closed by the Frame. I was reading about socket my app could can communicate with a website and if the communication between them I could detect that the program was closed but I dont really too much about it I just want to detect when my app stop running