Search code examples
androidmultithreadingmessageone-time-password

android:If not happen in 15 seconds do this condition


I want to add a condition on OTP recieve app.In which if its not signing up automatically when message come after 15 seconds it should allow the user to manually enter the OTP.I think there must be use of thread or handler?


Solution

  •    private CountDownTimer countDownTimer = new CountDownTimer(15000, 1000 / 100) {
        @Override
        public void onTick(long l) {
           // call when timer start
        }
    
        @Override
        public void onFinish() {
    
            Toast.makeText(MainActivity.this, "Done",    Toast.LENGTH_SHORT).show();
        }
    };
    

    to start Timer

    countDownTimer.start()