Need advice in how to update my Activity due to contact info changes
I have an activity which queries and display some Contact Information. It has a button which launches the intent for 'Edit Contact' (the default Android activity).
What should I do to refresh my view in case user edits Contact Information?
- re-query 开发者_如何学Goin the
onResume()
of my activity? - add a content observer?
I would suggest a content observer. If you requery in onResume then you'll be requerying when they leave and return for other reasons as well. Which is more wasteful than using the content observer.
I've seen that the contacts ContentObserver
doesn't always fire in every case. For example, I seem to recall that editing an existing phone number didn't necessarily trigger an update.
Querying every time should be relatively quick anyway if you want to do that, but if the EDIT
action returns a result (i.e. when called via startActivityForResult
), you could use that as a trigger to requery the contact information only as appropriate.
精彩评论