Welcome back.
One thing that you might have noticed is the fact that even though we made changes to my profile and
now it's not Homer about Homer Simpson and also the image is a different one.
There are no changes on this screen here.
All right.
So if we go to my profile, we can see that it's a different detail that we see here.
So Homer Simpson, instead of just Homer, if we update, we go back to the project manager screen here
and no changes.
So that is something that we will change now because we will start this activity as a real activity
for result activity.
All right.
So basically, you want to get a response and then based on that, we want to do things.
So let's go ahead and just implement the functionality for that.
So, first of all, I'm going to create a companion object in my main activity so that I can create
some constants in there.
So let's go over to the activities here and then the main activity.
So here, companion object, which will simply contain information about our profile request code.
So while my profile request code and I'm going to assign 11 to it, so let's define it as an integer,
just to be sure, even though it shouldn't be necessary.
But still now it's an integer and we can go ahead and use it.
So the next step we will need to do is to start the activity for result once we click on the navigation
item.
So here in our own navigation item selected, we have this nav my profile and we start the activity,
but not for a specific result.
So that is what we want to change now.
So we're just going to add the four result year for result.
And if we do that, we also need to enter the request code that we want to pass.
OK, so let's at.
Hey, come on here and at my profile request code.
OK, so overall, this intent is going to look like this.
You can see he has not activity for assault with the intent and then with my profile request code,
then the third step is to send the result from my profile activity, because at one point we need to
send the result.
Right.
And I'd say we should set the result once we click on the update.
Profile success.
So profile update, success function, progress bar.
And here at this point, let's set the result as being activity
result.
OK.
OK, so once we update it and we click on this button, the result will be OK and we can hear and this
function now have an on activity result override.
So our activity result.
And here we can check if the result code was resolved.
OK, so if result code is equal to activity, dot result.
OK, and the request code was in fact the one that we prepared, which is my profile request code.
So if that is given so those things are given, what we need to do is we need to load the user data
and this activity.
So via store class that loads user data.
And she would need to pass him the activity, so we just passing the main activity and if it was something
else, so if we got an error, we can just log on her right here.
Logi canceled and the message could be also canceled.
Going to be, of course, more descriptive here on activity result or something at that canceled.
So whatever you want to add here to be more descriptive.
But at this point, we should be able to test this and see if it's going to give us the required result.
All right, so Peruggia Menasche.
Now, let's look at it, we can see now it's going to be Homer Simpson, of course it will be, because.
Now loaded the whole page and again, of course, it loaded the user data because that is what is done
when the page is loaded, right.
But now let's make changes in my profile.
Let's now call this guy Homer.
Again, it's Homer Simpson, it's Homer again.
Let's update.
And let's have a look and see now again.
All right, so that seemed to work.
Now you can see how you can make these changes without having to load the whole database once again
when you come back without having this clean approach that we use.
So now we start the activity because this profile page is really just a pop up, so to speak.
OK, so we are opening it and once we go back, we want to.
Make changes, if we press the button, however, then canceled will be executed, so let's have a look
consult.
We can see we get this error here.
It says cancelled.
All right, so let's go ahead to the next video, see you there.