How can I get the last intent sent to an activity?
The docs for onNewIntent()
suggest I would need to do something like this:
class MyActivity {
public void onNewIntent(Intent intent){
setIntent(intent);
reactToIntentAndDoStuff()
super.onNewIntent(Intent intent);
}
public void onCreate(){
reactToIntentAndDoStuff()
super.onCreate();
}
public void onResume(){
reactToIntentAndDoStuff()
super.onResume();
}
public void reactToIntentAndDoStuff(){
Intent intent = getIntent();
}
}
Does this look about right? Or is there a better way? My activity's launchMode
will be singleTop
. It will need to react to the same Intent in more or less the same way, whether it's already instantiated or not.