Build 1.0_r1(from source)

android.accounts
Class AccountMonitor

java.lang.Object
  extended by android.content.BroadcastReceiver
      extended by android.accounts.AccountMonitor
All Implemented Interfaces:
ServiceConnection

public class AccountMonitor
extends BroadcastReceiver
implements ServiceConnection

A helper class that calls back on the provided AccountMonitorListener with the set of current accounts both when it gets created and whenever the set changes. It does this by binding to the AccountsService and registering to receive the intent broadcast when the set of accounts is changed. The connection to the accounts service is only made when it needs to fetch the current list of accounts (that is, when the AccountMonitor is first created, and when the intent is received).


Constructor Summary
AccountMonitor(Context context, AccountMonitorListener listener)
          Initializes the AccountMonitor and initiates a bind to the AccountsService to get the initial account list.
 
Method Summary
 void close()
          Unregisters the account receiver.
protected  void finalize()
          calls close()
 void onReceive(Context context, Intent intent)
          This method is called when the BroadcastReceiver is receiving an Intent broadcast.
 void onServiceConnected(ComponentName className, IBinder service)
          Called when a connection to the Service has been established, with the IBinder of the communication channel to the Service.
 void onServiceDisconnected(ComponentName className)
          Called when a connection to the Service has been lost.
 
Methods inherited from class android.content.BroadcastReceiver
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountMonitor

public AccountMonitor(Context context,
                      AccountMonitorListener listener)
Initializes the AccountMonitor and initiates a bind to the AccountsService to get the initial account list. For 1.0, the "list" is always a single account.

Parameters:
context - the context we are running in
listener - the user to notify when the account set changes
Method Detail

onReceive

public void onReceive(Context context,
                      Intent intent)
Description copied from class: BroadcastReceiver
This method is called when the BroadcastReceiver is receiving an Intent broadcast. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values. The function is normally called from the main thread of its process, so you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive().

If this BroadcastReceiver was launched through a <receiver> tag, then the object is no longer alive after returning from this function. This means you should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use Context.startService(Intent) instead of Context.bindService(Intent, ServiceConnection, int).

Specified by:
onReceive in class BroadcastReceiver
Parameters:
context - The Context in which the receiver is running.
intent - The Intent being received.

onServiceConnected

public void onServiceConnected(ComponentName className,
                               IBinder service)
Description copied from interface: ServiceConnection
Called when a connection to the Service has been established, with the IBinder of the communication channel to the Service.

Specified by:
onServiceConnected in interface ServiceConnection
Parameters:
className - The concrete component name of the service that has been connected.
service - The IBinder of the Service's communication channel, which you can now make calls on.

onServiceDisconnected

public void onServiceDisconnected(ComponentName className)
Description copied from interface: ServiceConnection
Called when a connection to the Service has been lost. This typically happens when the process hosting the service has crashed or been killed. This does not remove the ServiceConnection itself -- this binding to the service will remain active, and you will receive a call to ServiceConnection.onServiceConnected(android.content.ComponentName, android.os.IBinder) when the Service is next running.

Specified by:
onServiceDisconnected in interface ServiceConnection
Parameters:
className - The concrete component name of the service whose connection has been lost.

finalize

protected void finalize()
                 throws Throwable
calls close()

Overrides:
finalize in class Object
Throws:
Throwable

close

public void close()
Unregisters the account receiver. Consecutive calls to this method are harmless, but also do nothing. Once this call is made no more notifications will occur.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature