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
9
votes
4 answers

Why and when to unregister content observers in android

I am developing an android application and first time working with content observers. So I read a lot of tutorials and got the concept that why it is provided and how to use. Now I have read these lines on a blog that Dont forget to unregister…
Nikhil Agrawal
  • 26,128
  • 21
  • 90
  • 126
8
votes
1 answer

FIleObserver and ContentObserver not working in Android Marshmallow

I have issue with both FIleObserver and ContentObserver not working in Android Marshmallow. I am using this thing for detecting changes that happening inside a folder. I set run time permissions for marshmallow. But after that also it shows no…
7
votes
4 answers

Sms ContentObserver onChange() fires multiple times

I know this question has been asked multiple times, but nobody has been able to come up with a working answer from what I have seen. Im working on an app to intercept text messages and depending on the sending #, pop up with a custom alert. I have…
r2DoesInc
  • 3,759
  • 3
  • 29
  • 60
7
votes
3 answers

Android: Detect SMS Outgoing, Incorrect Count

I am trying to make an application to count the number of outgoing SMS messages from a phone. Presently I have the following code: private void listenForSMS(){ Log.v("SMSTEST", "STARTED LISTENING FOR SMS OUTGOING"); Handler handle = new…
Joshua Abrams
  • 377
  • 1
  • 5
  • 17
7
votes
3 answers

notifyChange with changed uri from contentProvider.update()

i have implemented update() of ContentProvider and notifying to observer using getContext().getContentResolver().notifyChange(uri, null); my obvious need is that whenever just one row is effected i want to notify with row specific uri, but could not…
6
votes
2 answers

Receive contact changes (added, deleted and changed)

Isn't there a timestamp for each contact? I need to be notified by a change (add, delele or change) to a contact. I've implemented a ContentObserver, but trough this method I'm only able to be notified if a change occurs on a contact, but I don't…
6
votes
2 answers

Android: content observer for content://sms/sent not working

I have been working with content observers for a while. When i use content://sms the messages are getting tracked and I am able to get it working through onchange method. But when I change it to content://sms/sent it is not working. I am not…
Vivek
  • 4,526
  • 17
  • 56
  • 69
6
votes
1 answer

Android: How to register a content observer without an activity?

I need to listen all incoming and outgoing sms and store it in a text file. For this I am using broadcast listener to listen all incoming messages. This works fine. But for outgoing sms, how to register content observer without activity? I don't…
Vivek
  • 4,526
  • 17
  • 56
  • 69
6
votes
0 answers

How to get notifications of changes in contacts even when the application is closed

My app "syncs" all the contacts on a phone with the server. However, part of the requirement is that if any contact is inserted, updated, or deleted then the sync must happen again to maintain data integrity. I know about registering a…
6
votes
2 answers

How to handle REST calls, data persistence, syncing and observing ContentProvider

I know that this question has been asked too many times, but I think the issues I'm trying to target are a little bit different, maybe more complicated. I am going to develop an application that uses a RESTful Web Service and needs to have the…
5
votes
1 answer

Contacts ContentObserver called randomly

i am using a ContentObserver to listen for changes in the contacts database. now i realized that the onChange() method gets randomly called, even if i have not made any changes to the contacts. i suspect this is somehow related to the automatic…
SimonSays
  • 10,867
  • 7
  • 44
  • 59
5
votes
2 answers

SMS sent observer executes 3 times

I have defined the following service with an observer of messages sent. The problem is that when sending a message, I sense that is called 3 times onChange method of contentobserver. ¿Someone know tell me why? Thanks public class DSMSService…
itaravika
  • 391
  • 1
  • 6
  • 17
5
votes
0 answers

Why do android kills the client process which holds the cursor on content provider on another process in this case?

My app runs in Process1 and I'm using a content provider provided by another app which runs under Process2. When Process2 kills it's causing my app which runs under Process1 to be killed. 09-14 23:31:52.583 782 1351 I ActivityManager: Killing…
5
votes
2 answers

Block outgoing SMS by contentObserver

I want to block SMS by contentObserver. For that I want to get the phone number of the SMS first. What do I do to get the number? This is the code that I have, just counting the number of SMS. package com.SMSObserver4; import…
5
votes
1 answer

Contacts backup and sync application

I am working on a contacts backup and sync. The target is to send all details of all contacts to a server (custom protocol defined) as a backup. During initial launch of application, all the contacts will be queued and sent to the server. And after…
Udayan
  • 1,374
  • 1
  • 11
  • 20
1
2
3
17 18