Finishing all activities started before the activity

前端 未结 3 1538
难免孤独
难免孤独 2021-02-09 15:16

I want to finish all the activities which are running in the application means want to remove all the parent activities from stack.

I want to implement logout functional

3条回答
  •  隐瞒了意图╮
    2021-02-09 16:01

    Try this one if you're targetting APi Level <11

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

提交回复
热议问题