Get the Intent that woke up my activity

后端 未结 2 592
时光说笑
时光说笑 2021-01-22 14:05

I\'m developing an application that includes a broadcast receiver. The broadcast receiver sets a notification onReceive(), which includes a pending Intent

Inten         


        
相关标签:
2条回答
  • 2021-01-22 14:24

    when the activity was sleeping

    Activities don't sleep. I am assuming that you mean that the activity was in the background.

    How can I get the Intent that woke up my activity?

    Add FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP as flags to your Intent. Then, your activity will get this Intent passed to it via onNewIntent().

    0 讨论(0)
  • 2021-01-22 14:31

    I think the problem is that when an activity is woken, getIntent() returns the intent that first started it.

    0 讨论(0)
提交回复
热议问题