I’ve read that it’s bad practice for an activity in the foreground to try to communicate/manipulate an activity in the background, and that generally the onResume function should be used.
So I’ve got one activity that lets a user add a “favorite” thing. There’s another activity that shows a list of all the favorited things. Instead of querying the DB and rebuilding the list each time onResume, I’m using a class with just static flags like “favorites_updated”, and if it’s true, onResume we do the extra work – if it’s false we don’t bother.
This feels a little clunky – is there a more established way of doing something like this?
TYIA.
You can also create a listner for the change in favorite list in background activity and on change you can notify your back activity.
This method has an advantage as you don’t have code a lot of changes in onResume.