ContentObserverpublic abstract class ContentObserver extends Object Receives call backs for changes to content.
Must be implemented by objects which are added to a {@link ContentObservable}. |
Fields Summary |
---|
private final Object | mLock | private Transport | mTransport | android.os.Handler | mHandler |
Constructors Summary |
---|
public ContentObserver(android.os.Handler handler)Creates a content observer.
mHandler = handler;
|
Methods Summary |
---|
public boolean | deliverSelfNotifications()Returns true if this observer is interested receiving self-change notifications.
Subclasses should override this method to indicate whether the observer
is interested in receiving notifications for changes that it made to the
content itself.
return false;
| private void | dispatchChange(boolean selfChange, android.net.Uri uri, int userId)Dispatches a change notification to the observer. Includes the changed
content Uri when available and also the user whose content changed.
If a {@link Handler} was supplied to the {@link ContentObserver} constructor,
then a call to the {@link #onChange} method is posted to the handler's message queue.
Otherwise, the {@link #onChange} method is invoked immediately on this thread.
if (mHandler == null) {
onChange(selfChange, uri, userId);
} else {
mHandler.post(new NotificationRunnable(selfChange, uri, userId));
}
| public final void | dispatchChange(boolean selfChange)Dispatches a change notification to the observer.
If a {@link Handler} was supplied to the {@link ContentObserver} constructor,
then a call to the {@link #onChange} method is posted to the handler's message queue.
Otherwise, the {@link #onChange} method is invoked immediately on this thread.
dispatchChange(selfChange, null);
| public final void | dispatchChange(boolean selfChange, android.net.Uri uri)Dispatches a change notification to the observer.
Includes the changed content Uri when available.
If a {@link Handler} was supplied to the {@link ContentObserver} constructor,
then a call to the {@link #onChange} method is posted to the handler's message queue.
Otherwise, the {@link #onChange} method is invoked immediately on this thread.
dispatchChange(selfChange, uri, UserHandle.getCallingUserId());
| public IContentObserver | getContentObserver()Gets access to the binder transport object. Not for public consumption.
{@hide}
synchronized (mLock) {
if (mTransport == null) {
mTransport = new Transport(this);
}
return mTransport;
}
| public void | onChange(boolean selfChange)This method is called when a content change occurs.
Subclasses should override this method to handle content changes.
// Do nothing. Subclass should override.
| public void | onChange(boolean selfChange, android.net.Uri uri)This method is called when a content change occurs.
Includes the changed content Uri when available.
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 {@link #onChange(boolean)} overload of this method whenever they
implement the {@link #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.
{@literal @Override}
public void onChange(boolean selfChange) {
onChange(selfChange, null);
}
// Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument.
{@literal @Override}
public void onChange(boolean selfChange, Uri uri) {
// Handle change.
}
onChange(selfChange);
| public void | onChange(boolean selfChange, android.net.Uri uri, int userId)Dispatches a change notification to the observer. Includes the changed
content Uri when available and also the user whose content changed.
onChange(selfChange, uri);
| public IContentObserver | releaseContentObserver()Gets access to the binder transport object, and unlinks the transport object
from the ContentObserver. Not for public consumption.
{@hide}
synchronized (mLock) {
final Transport oldTransport = mTransport;
if (oldTransport != null) {
oldTransport.releaseContentObserver();
mTransport = null;
}
return oldTransport;
}
|
|