开发者

Back button edit action

I have a splash screen and if I press the back button while the splash activity is running this activity is closed but the next activity after the splash (after 2 seconds) will be open. I would like to set the back button to close the splash a开发者_C百科ctivity but to open immediately the next activity or to close the whole application.


You need to override the back-button with this:

    @Override
    public void onBackPressed(){
       Intent i1 = new Intent(getApplicationContext(), NextActivity.class);
       startActivity(i1);
    return; 

This will take you to the next Activity when you pres the button. If you want to close the app try this:

        @Override
        public void onBackPressed(){
            moveTaskToBack(true);
        return;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜