如何5秒钟后自动显示一个活动 [英] how to display an activity automatically after 5 seconds

查看:150
本文介绍了如何5秒钟后自动显示一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序已经在Android中创造的东西闪屏类型。应该保持5秒钟。我的问题是,如何我后5秒自动显示另一个活动?启动屏幕没有按钮,而是应该没有按一下按钮5秒钟后自动显示另一个活动。

解决方案

 新的处理程序()。postDelayed(新的Runnable(){
            @覆盖
            公共无效的run(){
                最终意图mainIntent =新的意图(LaunchActivity.this,HomeActivity.class);
                LaunchActivity.this.startActivity(mainIntent);
                LaunchActivity.this.finish();
            }
        },5000);
 

In my application I have created a splash screen type of thing in android. It should remain for 5 seconds. My problem is that how I display another activity automatically after 5 secs? The splash screen doesn't have a button, rather it should display another activity automatically after 5 seconds without the click of the button.

解决方案

new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                final Intent mainIntent = new Intent(LaunchActivity.this, HomeActivity.class);
                LaunchActivity.this.startActivity(mainIntent);
                LaunchActivity.this.finish();
            }
        }, 5000);

这篇关于如何5秒钟后自动显示一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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