Update model objects across different activities

Posted by Tom Esterez on Stack Overflow See other posts from Stack Overflow or by Tom Esterez
Published on 2011-01-04T21:39:02Z Indexed on 2011/01/04 21:54 UTC
Read the original article Hit count: 168

Filed under:
|

Lets say I have 2 activities:

  • A: A ListView displaying articles titles. Data is fetched from a web server and converted from XML to a list of ArticleSummary. Only user titles and id are returned by the server. Click on a title starts activity B.
  • B: A form to edit an article. Article is fetched from server. When the user hits OK, modifications are sent to the server and activity closed.

When the user go back to activity A, I would like to update the article title without any additional web request.

I was thinking about the following solution:

  1. When article is modified, send a broadcast event with article id and new attributes values.
  2. Listen for this event on activity A
  3. Update the ArticleSummary object
  4. notify data changed on ListView

Is there a better approach ?

© Stack Overflow or respective owner

Related posts about android

Related posts about architecture