I'm working on an app for Android 4.0 and later using Java.
I want to set a timeout method in java that starts automatically and runs a method after 5 seconds.
Please tell me how to do that with explanation.
I researched a lot about it on the Internet, but I couldn't get any result.
This will solve your problem :
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
// Your method code here
}
};
timer.schedule(task, 5000);