调用完成()后,开始一个新的活动 [英] Calling finish() After Starting a New Activity

查看:110
本文介绍了调用完成()后,开始一个新的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载在我的应用程序中的第一个活动是一个初始化的活动,一旦完成它加载一个新的活动。我要确保,如果用户presses'后退',他们直接进入启动程序,而不是初始化屏幕。 侧面说明,这即使是最好的办法,还是将这种具有某种意图国旗来做得更好?

The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is this even the best approach, or would this be better done with some kind of Intent Flag?

是否正确调用之后调用的完成() startActivity()的对新的活动?

Is it correct to call finish() after calling startActivity() on the new activity?

onCreate() {
...
startActivity(new Intent(this, NextActivity.class));
finish();
...
}

我仍然采取处事Android中的整个消息队列的方法,我的假设是,调用的 startActivity()的,然后的完成()的从我的第一个活动的的的onCreate()的将记录在消息队列中每个相应的消息,但执行完成的的onCreate()的移动到开始下一个活动,并完成我的第一个前一。这是一个正确的认识?

I'm still taking in the whole 'Message Queue' method of doing things in Android, and my assumption is that calling startActivity() and then finish() from my first Activity's onCreate() will log each respective message in the message queue, but finish execution of onCreate() before moving on to starting the next Activity and finishing my first one. Is this a correct understanding?

推荐答案

也许你应该使用的上的活动noHistory 把你的manifest.xml

Probably you should just use the noHistory flag on the activity in your manifest.xml

这篇关于调用完成()后,开始一个新的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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