0

I have a single ActionbarActivity with two fragments. I have a menu option (maintained in MainActivity) to open a camera intent and capture a picture. When I return from this event, I want to update the first fragment.

Currently, if I select this menu option while the first fragment is visible, I can update the UI by using a reference to an instance in the MainActivty's onActivityResult(). However, if the second fragment is currently visible, the app crashes. (I am away from Android Studio but will be able to post error message shortly, if necessary.)

How can I - from the MainActivity's onActivtyResult() or elsewhere - ensure that the saved instance of the first fragment is returned to and updated, regardless of which fragment is currently visible when the option was selected? Or is it just as easy to create a new instance of the first fragment? (It would be created with the updated information automatically.)

Juan
  • 1,428
  • 2
  • 22
  • 30
sk8pickel
  • 43
  • 4

1 Answers1

0

you can get existing fragments through the FragmentManager from the Activity.

see here how to do this.

Community
  • 1
  • 1
Paul Reznik
  • 965
  • 1
  • 6
  • 18