Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I refresh the data (and the corresponding view) inside a fragment from another activity?
    text
    copied!<p>Have tried searching and tested all possibilities on StackOverflow but I'm still stuck, so many apologies if this seems like a duplicate!</p> <p><strong>Here's an overview on what I'm trying to achieve:</strong></p> <p>I have a user profile. It is made up of UserProfileActivity and UserProfileFragment, where the view and data projections are handled in the fragment. A user ID (objectId) is also being passed to display the profile of the respective user. </p> <p>On this user profile, you can click to a list of the user's followers (made up of ListFollowerActivity and ListFollowerFragment). On this list of followers, clicking on an individual person leads to UserProfileActivity again, this time with a different user ID.</p> <p><strong>What's happening currently:</strong></p> <p>The code I currently use to load the UserProfileActivity (with a new user ID) from the ListFollowerFragment is;</p> <pre><code>Intent intent = new Intent(parent, UserProfileActivity.class); Bundle bundle = new Bundle(); bundle.putString(C.bundleKey.objectId, objectId); // objectId = user ID! intent.putExtras(bundle); startActivity(intent); </code></pre> <p>I've done a out.println on the object ID from the reload intent in ListFollowerFragment and it correctly prints the correct user ID. (The ID of the user which is tapped on.)</p> <p>But in reality, the app reloads the same user profile (which is the former user ID and not the new one) again.</p> <p>How do I get the UserProfileFragment to refresh the data (and the view) to reflect the correct user?</p> <p><em>Some observations:</em> It seems that UserProfileActivity is simply 'restoring' from its previous state (previous user ID) from second and subsequent loads. (Any out.println() I do from onCreate() in UserProfileActivity and onCreateView() in UserProfileFragment is not readable from the second load onwards, but reads correctly on the first!)</p> <p>I've also attempted finish() on UserProfileActivity when navigating to ListFollowerActivity, and all subsequent loads of UserProfileActivity worked with the correct user Ids, presumably because the activity is killed and restarted. But this also means the user is unable to back-navigate. Would really appreciate any help. Thanks! (:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload