开发者

Calling finish() After Starting a New Activity

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 F开发者_运维知识库lag?

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

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

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜