Questions tagged [contentobserver]

Receives call backs for changes to content. Must be implemented by objects which are added to a ContentObservable.

Receives call backs for changes to content. Must be implemented by objects which are added to a ContentObservable.

It has the following public meathods

Public Methods

boolean deliverSelfNotifications()

Returns true if this observer is interested receiving self-change notifications.

final void dispatchChange(boolean selfChange, Uri uri)

Dispatches a change notification to the observer.

final void dispatchChange(boolean selfChange)

This method was deprecated in API level 16. Use dispatchChange(boolean, Uri) instead.

void onChange(boolean selfChange, Uri uri)

This method is called when a content change occurs.

void onChange(boolean selfChange)

This method is called when a content change occurs.

259 questions
3
votes
2 answers

Listening to outgoing sms not working android

I am trying to listen to outgoing sms messages. I was following the accepted answer here but it is not working. I'm not sure where I am going wrong. I am no familiar at all with Content Observers so forgive my ignorance. I wanted to create it in a…
Santi Gallego
  • 202
  • 1
  • 18
3
votes
0 answers

get contact number when contact is added / change / delete

I want contact number for my android application when any new contact added or contact is edited / deleted from android in built app. I have tried below code. public class MainActivity extends Activity{ MyContentObserver contentObserver = new…
Ram Mansawala
  • 652
  • 7
  • 22
3
votes
1 answer

Android : Catching Outgoing SMS using ContentObserver or receiver not working

i trying to catch outgoing SMS event using content observer. //TEST OBSERVER ContentObserver co = new SMSoutObserver(new Handler(), getApplicationContext()); ContentResolver contentResolver =…
redrom
  • 11,502
  • 31
  • 157
  • 264
3
votes
2 answers

how to know if a contact is added, changed or deleted in android

I am working on an application whereby I need to listen to changes in native contacts database like if a contact is edited/deleted or a new contact is added. I know I can achieve this with the help of contentobservers. However I found it pretty…
sangram
  • 141
  • 2
  • 8
3
votes
2 answers

ContentObserver not working in android

Hi I am trying with the below code.The content resolver is not working with this.Can anyone give an idea getContentResolver().registerContentObserver(MyContentProvider.CONTENT_URI,true, new ContentObserver(new Handler()){ @Override public void…
V I J E S H
  • 7,464
  • 10
  • 29
  • 37
3
votes
1 answer

ContentObserver onChange() is not being called.

I have a ContentProvider. My update method in my content provider is : @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { int count = 0; switch (uriMatcher.match(uri)){ …
Aleena
  • 273
  • 4
  • 12
3
votes
1 answer

How to implement ContentObserver?

I have a ContentProvider , using it I am populating my ListView. I need to click one of the menu-item. It updates my data sets but i need to reflect the changes in the ListView. I read about ContentObserver but i am still confused how to implement…
Aleena
  • 273
  • 4
  • 12
3
votes
0 answers

Detecting outgoing sms android

I'm using a ContentObserver to detect outgoing messages. The problem is that onChange() fires three times whenever a message is sent. I've been looking through some answers on SO and it appears to be because three tables are updated each time a…
Frederikkastrup
  • 243
  • 1
  • 3
  • 11
3
votes
2 answers

In what circumstances is uri passed to Android's ContentObserver.onChange() callback?

The onChange() method of Android's ContentObserver class says, "Includes the changed content Uri when available." In what circumstances is the URI available? In what circumstances is it not available? The uri parameter was added in API level 16…
Mark Doliner
  • 1,543
  • 15
  • 17
3
votes
1 answer

Android - unregister ContentObserver defined in Adapter

I have a series of files to upload. Those are stored as entries in a Content Provider. Each entry also contains the percentage uploaded. One activity displays a list of uploads, each file is an item with a ProgressBar to show the progress of the…
ticofab
  • 7,551
  • 13
  • 49
  • 90
3
votes
0 answers

ContentObserver or BroadcastReceiver for incoming SMS?

In order to capture incoming SMS in Android, I know that I can either use a ContentObserver that looks at content:/sms/, or I can register a BroadcastReceiver. What are the pros and cons of these two methods? Is one more reliable than the other? Is…
NYCHippo
  • 377
  • 1
  • 4
  • 14
3
votes
1 answer

Content Observer with Files?

So my Question is to know if ContentObserver can be used to Monitor a Folder and get Notified when a file is Created/Removed ? in my Case , i want to Monitor the Camera Folder and get Notified when a new file is Created (Picture Taken) , Thanks .
user1839514
  • 221
  • 1
  • 2
  • 10
3
votes
1 answer

getting changed uri on ContentObserver Onchange on older versions of the API

Possible Duplicate: How to get URI of inserted row in my content observer? I am using ContentObserver to listen to changes on a content provider. However, I was wondering if there is a way to get the changed URI when the OnChange method is called…
Thomas
  • 2,751
  • 5
  • 31
  • 52
3
votes
1 answer

Lifecycle of a ContentObserver?

What is the life-cycle of a ContentObserver? Once registered, does it persist after the app has been closed? If the ContentObserver is unregistered after the app is closed, is there a way around this? For my specific case, I want to monitor the…
Shane
  • 2,315
  • 3
  • 21
  • 33
3
votes
1 answer

How to detect new apps in an Android device

I want to detect when the user installs or deletes an app, and I didn't find a BroadcastReceiver that does this. In my app, I get the information about the installed apps with the class PackageManager, but I don't want to scan the apps periodically.…