public final class AuthenticatorHelper extends BroadcastReceiver
AuthenticatorHelper.OnAccountsUpdateListener
.
AuthenticatorHelper.OnAccountsUpdateListener.onAccountsUpdate(UserHandle)
will then be
called once accounts get updated. For setting up listening for account
updates, listenToAccountUpdates()
and
stopListeningToAccountUpdates()
should be used.Modifier and Type | Class and Description |
---|---|
static interface |
AuthenticatorHelper.OnAccountsUpdateListener |
BroadcastReceiver.PendingResult
Constructor and Description |
---|
AuthenticatorHelper(Context context,
UserHandle userHandle,
AuthenticatorHelper.OnAccountsUpdateListener listener) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsAccountType(String accountType) |
AuthenticatorDescription |
getAccountTypeDescription(String accountType) |
ArrayList<String> |
getAuthoritiesForAccountType(String type) |
Drawable |
getDrawableForType(Context context,
String accountType)
Gets an icon associated with a particular account type.
|
String[] |
getEnabledAccountTypes() |
CharSequence |
getLabelForType(Context context,
String accountType)
Gets the label associated with a particular account type.
|
int |
getLabelIdForType(String accountType)
Gets the resource id of the label associated with a particular account type.
|
String |
getPackageForType(String accountType)
Gets the package associated with a particular account type.
|
boolean |
hasAccountPreferences(String accountType) |
void |
listenToAccountUpdates() |
void |
onReceive(Context context,
Intent intent)
This method is called when the BroadcastReceiver is receiving an Intent
broadcast.
|
void |
preloadDrawableForType(Context context,
String accountType) |
void |
stopListeningToAccountUpdates() |
void |
updateAuthDescriptions(Context context)
Updates provider icons.
|
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getPendingResult, getResultCode, getResultData, getResultExtras, getSendingUserId, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setPendingResult, setResult, setResultCode, setResultData, setResultExtras
public AuthenticatorHelper(Context context, UserHandle userHandle, AuthenticatorHelper.OnAccountsUpdateListener listener)
public String[] getEnabledAccountTypes()
public Drawable getDrawableForType(Context context, String accountType)
accountType
- the type of accountPackageManager.getDefaultActivityIcon()
if one cannot be found.public CharSequence getLabelForType(Context context, String accountType)
accountType
- the type of accountpublic String getPackageForType(String accountType)
accountType
- the type of accountpublic int getLabelIdForType(String accountType)
accountType
- the type of accountpublic void updateAuthDescriptions(Context context)
public boolean containsAccountType(String accountType)
public AuthenticatorDescription getAccountTypeDescription(String accountType)
public boolean hasAccountPreferences(String accountType)
public void onReceive(Context context, Intent intent)
BroadcastReceiver
Context.registerReceiver(BroadcastReceiver,
IntentFilter, String, android.os.Handler)
. When it runs on the main
thread 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)
. If you wish
to interact with a service that is already running, you can use
BroadcastReceiver.peekService(android.content.Context, android.content.Intent)
.
The Intent filters used in Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
and in application manifests are not guaranteed to be exclusive. They
are hints to the operating system about how to find suitable recipients. It is
possible for senders to force delivery to specific recipients, bypassing filter
resolution. For this reason, onReceive()
implementations should respond only to known actions, ignoring any unexpected
Intents that they may receive.
onReceive
in class BroadcastReceiver
context
- The Context in which the receiver is running.intent
- The Intent being received.public void listenToAccountUpdates()
public void stopListeningToAccountUpdates()