Android, Intent.FLAG_ACTIVITY_CLEAR_TOP seems doesn't work?

后端 未结 6 579
忘掉有多难
忘掉有多难 2020-12-16 08:25

In my menu I have some items. Home is an item of it that I want to be root of my application and whenever user clicks on it, Android clear stack and then come back to main s

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 08:39

    I have tried Intent.FLAG_ACTIVITY_CLEAR_TOP But haven't got proper solution so finally this helps me

    
    Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
    ComponentName cn = intent.getComponent();
    Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
    startActivity(mainIntent);
    
    

    This clears all the stack and run only LoginActivity

提交回复
热议问题