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 in the onResume() of my activity?
  • add a content observer?


Asked by: Rafael582 | Posted: 25-01-2022






Answer 1

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.

Answered by: Catherine478 | Posted: 26-02-2022



Answer 2

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.

Answered by: Thomas737 | Posted: 26-02-2022



Similar questions

android - Launch activity at certain time

I'm new to Android development, so I might be missing something obvious. I want to launch an Activity when the user's phone clock hits a specified time (similar to an alarm). However, I'm not sure how I would go about doing this as constant polling of the clock seems inefficient and a waste of resources. Do I need to capture broadcast events from the clock, or use PendingIntents? If someone could ...


android - How to to make 2 MapView on one Activity?

Is it possible to make 2 MapView on one Activity ? If so, How to make it ? I've tried but no luck. Thanks in advance.


How to change title of Activity in Android?

I am using Window w = getWindow(); w.setTitle("My title"); to change title of my current Activity but it does not seem to work. Can anyone guide me on how to change this?


android - Replace current activity

I need to replace the current activity with a new one. That is, I want to start a new activity and remove the current activity from the task stack. Based on the documentation, it seems the best way would be to start the activity using Activity.startActivity as per usual, and then cal...


android - How to enforce activity if app is running?

I start an Activity from my Widget, which should start a special view. But if the app is already running (not left with back button), Android instead activates the activity that was last shown. Is there any flag or other way to avoid this behaviour? Closing the previous activity wouldn't be a problem in my app, there's no user input that would be lost. I tried a workaround with finish() in onStop(), but onS...


How can android find a certain activity or service based on a given Intent?

Suppose that I installed app A and app B, app A has a main activity, and app B wants to show that activity by sending a intent. My question is that how android knows I have installed app A and is able to map the intent to its activity? Is there any windows-registry-like store saving such information? Thank You


Android - Make sure activity is alive before firing Intent?

I am currently firing an Intent to a Broadcast Receiver which in turns starts an Activity. Then from the same Service another Intent is fired to a Broadcast Receiver thats in the Activity. The problem is that the Activity isn't getting the Intent meant for it because it is fired before it is alive and the Broadcast Reciever is registered. I was wondering is there anyway to make sure an Activity is a...


java - How do I send some data (eg. a String) from my Activity to a Service ...in Android?

Usually, I putExtra inside an Intent to transfer stuff between Activities. But it seems like I can't do this with a Service? Bundle extras = getIntent().getExtras(); That doesn't work for a android Service. How do I send a string from an Activity to a Service then?


android - Save activity gui state

So I'm writing an app. I would like to be able to press the home key to leave the app, do something else for a moment, then come back to the app by picking it from the launcher. I want the app to have exactly the same state as it did when I left it. To this end, I have implimented onSaveInstanceState() to create a bundle, and I use this bundle in onCreate() (checking if it is null, of course). This is what I would ...


Should only 1 view go in 1 Activity, in Android?


android - Launch activity at certain time

I'm new to Android development, so I might be missing something obvious. I want to launch an Activity when the user's phone clock hits a specified time (similar to an alarm). However, I'm not sure how I would go about doing this as constant polling of the clock seems inefficient and a waste of resources. Do I need to capture broadcast events from the clock, or use PendingIntents? If someone could ...


android - How to to make 2 MapView on one Activity?

Is it possible to make 2 MapView on one Activity ? If so, How to make it ? I've tried but no luck. Thanks in advance.


eclipse - how to add image buttons in each Android activity?

can any one guide me how to add some menu related buttons at the bottom of each activity?


How to change title of Activity in Android?

I am using Window w = getWindow(); w.setTitle("My title"); to change title of my current Activity but it does not seem to work. Can anyone guide me on how to change this?


android - Replace current activity

I need to replace the current activity with a new one. That is, I want to start a new activity and remove the current activity from the task stack. Based on the documentation, it seems the best way would be to start the activity using Activity.startActivity as per usual, and then cal...


android - How to enforce activity if app is running?

I start an Activity from my Widget, which should start a special view. But if the app is already running (not left with back button), Android instead activates the activity that was last shown. Is there any flag or other way to avoid this behaviour? Closing the previous activity wouldn't be a problem in my app, there's no user input that would be lost. I tried a workaround with finish() in onStop(), but onS...


eclipse - How to display custom list activity in Android?

I want to display data in list activity. How do I achieve this? TITLE Date Sub Title Button TITLE Date Sub Title Button TITLE Date Sub Title Button . . . . and so on Does a tutorial exist related to custom list activity?


android dialog activity position

I created an non-maximized activity using android:theme="@android:style/Theme.Dialog" to make it looks like a dialog. I need to change the position of the activity on screen but I didn't find how to do this...


How can android find a certain activity or service based on a given Intent?

Suppose that I installed app A and app B, app A has a main activity, and app B wants to show that activity by sending a intent. My question is that how android knows I have installed app A and is able to map the intent to its activity? Is there any windows-registry-like store saving such information? Thank You


Android - Make sure activity is alive before firing Intent?

I am currently firing an Intent to a Broadcast Receiver which in turns starts an Activity. Then from the same Service another Intent is fired to a Broadcast Receiver thats in the Activity. The problem is that the Activity isn't getting the Intent meant for it because it is fired before it is alive and the Broadcast Reciever is registered. I was wondering is there anyway to make sure an Activity is a...






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top