Handler handler = new Handler(); handler.sendMessageDelayed(handler.obtainMessage(), 5000);
private Handler handler = new Handler(); private Button button = findViewById(R.id.button); private Runnable runnable = new Runnable() { @Override public void run() { // Perform task after button click } }; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Schedule task to run after 5 seconds handler.postDelayed(runnable, 5000); } });This code creates a runnable object that will be executed after the button has been clicked. The `handler.postDelayed` method schedules this runnable to run after 5 seconds. Overall, the `sendMessageDelayed` method is very useful for scheduling tasks to run after a specific amount of time has elapsed. It is part of the `android.os.Handler` package library.