how to force restart activity from intent

前端 未结 1 1757
时光取名叫无心
时光取名叫无心 2021-01-19 01:33

My MainActivity has the lauchMode=\"singleTask\"

Now I want to start the activity from a notification with special intent data. in Ma

1条回答
  •  借酒劲吻你
    2021-01-19 01:53

    onResume() is always called if the activity is not in the foreground. However, what you're probably seeing is that getIntent() is returning the intent that started the activity, not the intent that was most recently sent to it.

    To fix this, you should override onNewIntent(). This will receive the new intent sent to it. Then you can call setIntent() with the received intent, which will cause getIntent() to return the new intent when used in onResume().

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