Restart app to a certain activity?

前端 未结 2 1910
清歌不尽
清歌不尽 2021-01-07 14:17

I need to restart my app to a certain activity...is it possible?

When I restart it I don\'t want to start the first activity of application. How can I do this?

2条回答
  •  [愿得一人]
    2021-01-07 15:04

    In the onCreate method of the activity that is first launched you need to check if you want to go to another activity or not and then

    where restarted is some condition that check if your app was running before , you can use shared preferences to store some bool value

    if(restarted){
    
            Intent startActivity = new Intent();
            startActivity.setClass(this,OTHER_ACTIVITY.class);
            startActivity(startActivity); 
            finish();
    }else{
       //just normal flow
    }
    

提交回复
热议问题