一定时间后打开活动? [英] Open an activity after a certain amount of time?
本文介绍了一定时间后打开活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现我的应用程序一个闪屏。我找到了最好的和最简单的方法是推出一个活动,显示了在启动应用程序的图像视图的布局,然后添加机器人:noHistory =true属性的清单。 现在,我该如何设置启动画面活动到一定时间后启动MainActivity类?比方说2秒?
这是我的闪屏活性
公共类SplashActivity延伸活动{
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.splashscreen);
}
}
解决方案
使用
handler.postDelayed(可运行,delayinmilliseconds(2000你的情况));
最终的可运行可运行=新的Runnable()
{
公共无效的run()
{
//这里开始了新的活动。
}
};
I would like to implement a SplashScreen in my app. I found the best and easiest way is to launch an activity that shows a layout with an image view at the launch of the app and then adding android:noHistory="true" attribute to the manifest. Now, how do I set the splashscreen activity to launch the MainActivity class after a certain amount of time? Lets say 2 seconds?
This is my splashscreen activity
public class SplashActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
}
}
解决方案
use
handler.postDelayed(runnable, delayinmilliseconds(2000 in your case));
final Runnable runnable = new Runnable()
{
public void run()
{
//start the new activity here.
}
};
这篇关于一定时间后打开活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文