public abstract class ContentObserver extends Object
ContentObservable
.Constructor and Description |
---|
ContentObserver(Handler handler)
Creates a content observer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
deliverSelfNotifications()
Returns true if this observer is interested receiving self-change notifications.
|
void |
dispatchChange(boolean selfChange)
Deprecated.
Use
dispatchChange(boolean, Uri) instead. |
void |
dispatchChange(boolean selfChange,
Uri uri)
Dispatches a change notification to the observer.
|
IContentObserver |
getContentObserver()
Gets access to the binder transport object.
|
void |
onChange(boolean selfChange)
This method is called when a content change occurs.
|
void |
onChange(boolean selfChange,
Uri uri)
This method is called when a content change occurs.
|
IContentObserver |
releaseContentObserver()
Gets access to the binder transport object, and unlinks the transport object
from the ContentObserver.
|
public ContentObserver(Handler handler)
handler
- The handler to run onChange(boolean)
on, or null if none.public IContentObserver getContentObserver()
public IContentObserver releaseContentObserver()
public boolean deliverSelfNotifications()
public void onChange(boolean selfChange)
Subclasses should override this method to handle content changes.
selfChange
- True if this is a self-change notification.public void onChange(boolean selfChange, Uri uri)
Subclasses should override this method to handle content changes.
To ensure correct operation on older versions of the framework that
did not provide a Uri argument, applications should also implement
the onChange(boolean)
overload of this method whenever they
implement the onChange(boolean, Uri)
overload.
Example implementation:
// Implement the onChange(boolean) method to delegate the change notification to
// the onChange(boolean, Uri) method to ensure correct operation on older versions
// of the framework that did not have the onChange(boolean, Uri) method.
@Override
public void onChange(boolean selfChange) {
onChange(selfChange, null);
}
// Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument.
@Override
public void onChange(boolean selfChange, Uri uri) {
// Handle change.
}
selfChange
- True if this is a self-change notification.uri
- The Uri of the changed content, or null if unknown.@Deprecated public final void dispatchChange(boolean selfChange)
dispatchChange(boolean, Uri)
instead.
If a Handler
was supplied to the ContentObserver
constructor,
then a call to the onChange(boolean)
method is posted to the handler's message queue.
Otherwise, the onChange(boolean)
method is invoked immediately on this thread.
selfChange
- True if this is a self-change notification.public final void dispatchChange(boolean selfChange, Uri uri)
If a Handler
was supplied to the ContentObserver
constructor,
then a call to the onChange(boolean)
method is posted to the handler's message queue.
Otherwise, the onChange(boolean)
method is invoked immediately on this thread.
selfChange
- True if this is a self-change notification.uri
- The Uri of the changed content, or null if unknown.