在等待Android应用程序 [英] Waiting in android app

查看:112
本文介绍了在等待Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我用我的Andr​​oid程序线程等待第二个或更多,但有时它确实是赖特,有时它并不会等待,所以有可能另一种方式来等待几秒钟?

 发logotimer =新的Thread(){
    公共无效的run(){
        尝试{
            睡眠(1500);
            意图leveloverview =新的意向书(com.technopolisapp.FROGLEVEL);
            startActivity(leveloverview);
        }
        赶上(InterruptedException异常E){
            e.printStackTrace();
        }
        最后{
            完();
        }
    }
};

logotimer.start();
 

解决方案

相反,线程睡眠概念,你可以使用处理器...

 新的处理程序()。postDelayed(新的Runnable(){
    公共无效的run(){
        意图leveloverview =新的意向书(com.technopolisapp.FROGLEVEL);
        startActivity(leveloverview);
    }
},5000);
 

这code可以对你有所帮助......

So I'm using in my android program A thread to wait a second or more, but sometimes it does it wright and sometimes it doesn't wait at all, so is there maybe another way to wait a couple of seconds?

Thread logotimer = new Thread(){
    public void run(){
        try{
            sleep(1500);
            Intent leveloverview = new Intent("com.technopolisapp.FROGLEVEL");
            startActivity(leveloverview);
        }
        catch(InterruptedException e){
            e.printStackTrace();
        }
        finally{
            finish();
        }
    }
};

logotimer.start();

解决方案

Instead the thread sleeping concept you can use Handler...

new Handler().postDelayed(new Runnable(){
    public void run() {
        Intent leveloverview = new Intent("com.technopolisapp.FROGLEVEL");
        startActivity(leveloverview);
    }
}, 5000);

This code may be helpful for you...

这篇关于在等待Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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