I have an app that basically looks like the design in the attached picture. As you can see, there are 4 activities, and some of the activities have fragments.
I want to get the answer of a test back to the user's profile. Up to now, I've been uploading the result to the server and having the app update the user's profile every time they go back to the ProfileActivity, but that seems like a waste of resources.
Is there a pattern or way to do this in the app?
I looked at this: which seems doable if I can somehow link two startActivityForResult()
s.
I looked into using the delegate pattern described in this question but I can't get the instance of the UserFragment to the TestActivity.
I hope someone can point me in the direction of the correct way of doing this.
Assuming that you are getting one int value from last page:
create class :
than to set int value to it:
or
and in your very first activity where you want result:
or
selectedValue will return default value if there is no value in it. PS change int to String in class to get and set result accordingly.
One approach is use
startActivityForResult()
don't finish anyActivity
start all activities by
startActivityForResult()
then depending on your condition you can finish activitypass result back to the previous activity using
onActivityResult()
Then for fragment you can store fragment object in ProfileActivity . In Fragment write method for updating UI
So you can access that method using fragment object