Receiving consecutive SEND intents brings app back to the front, but does not update Intent

后端 未结 1 387
天命终不由人
天命终不由人 2021-01-26 20:25

On a project I\'m working on I\'ve come across an issue with receiving external intents, i.e. non-launcher intents. I have an Activity that can be started using the

1条回答
  •  太阳男子
    2021-01-26 20:57

    Add android:launchMode="singleTop" to the description.

    When the Activity is launched (if it isn't already running), Android will call onCreate() and you can get the Intent by calling getIntent() (like you are already doing).

    If the Activity is launched while your app is already running, Android will bring it to the foreground and will call onNewIntent() passing in the new Intent. You should override this method and do something with the passed Intent (save it in a member variable or extract what you want from it or whatever). After that Android will call onResume().

    Calling getIntent() will ALWAYS return the Intent that was used to originally start the Activity.

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