Issue
I'm writting my own plug-in for an existing game engine (so to say it's 3rd-party lib in relation to the main application).
So, I have no access to the MainActivity
sources.
Nevertheless I have to react somehow on main activity lifecycle
events (onCreate, onDestroy, onPause, onResume, onNewIntent
and some unimportant others).
Thanks to Application.ActivityLifecycleCallbacks
, I have no problems with most of them.
The problem occurs with onNewIntent(). I can't find out a listener
for this event and imagine a way to handle it.
Does anybody know how to catch onNewIntent
event (surely, except overriding it)?
Solution
onNewIntent() works for singleTop or singleTask activities which already run somewhere else in the stack. if the MainActivity is not declared with singleTop or singleTask attributes, even if you use below code, it won't work:
@Override //won't be called if no singleTop/singleTask attributes are used
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// ...
}
To assure all setup logic hooked, it is best use onResume() by utilizing getIntent().
@Override
protected void onResume() { //will be called in any cases
super.onResume();
// getIntent() should always return the most recent
}
Answered By - David
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.