android:如果15秒钟内未发生,请执行此条件 [英] android:If not happen in 15 seconds do this condition

查看:135
本文介绍了android:如果15秒钟内未发生,请执行此条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在OTP接收应用程序上添加一个条件.如果在15秒后消息出现时它没有自动注册,它应该允许用户手动输入OTP.我认为必须使用线程或处理程序吗?

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?

推荐答案

   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();
    }
};

启动计时器

countDownTimer.start()

这篇关于android:如果15秒钟内未发生,请执行此条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆