Android - Clear task flag not working for PendingIntent

后端 未结 9 1979
夕颜
夕颜 2020-12-17 09:34

I have a task stack of A > B > C. I am currently on C, and then I press the home button. I get a notification with the intent to take me to Activity A. I press the notificat

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 10:20

    My solution code:

        public class MyApplication extends Application{
        private static int activityCounter;
        public Activity A,B,C;
        public void incrementActivityCounter()
        {
            activityCounter++;
        }
        public void decrementActivityCounter()
        {
            activityCounter--;
            if (activityCounter == 0)
            {
                A.finish();
                B.finish();
                C.finish();
            }
        }
    }
    
    
    public class A extends Activity{
       @Override
        protected void onStart()
        {
            super.onStart();
            application.incrementActivityCounter();
        }
    
        @Override
        protected void onStop()
        {
            application.decrementActivityCounter();
            super.onStop();
        }
    }
    

提交回复
热议问题