本文整理汇总了Java中android.accounts.AuthenticatorDescription类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatorDescription类的具体用法?Java AuthenticatorDescription怎么用?Java AuthenticatorDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticatorDescription类属于android.accounts包,在下文中一共展示了AuthenticatorDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateServicesMap
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private void generateServicesMap(List<ResolveInfo> services, Map<String, AuthenticatorInfo> map,
IAccountParser accountParser) {
for (ResolveInfo info : services) {
XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo,
AccountManager.AUTHENTICATOR_META_DATA_NAME);
if (parser != null) {
try {
AttributeSet attributeSet = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
// Nothing to do
}
if (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
AuthenticatorDescription desc = parseAuthenticatorDescription(
accountParser.getResources(mContext, info.serviceInfo.applicationInfo),
info.serviceInfo.packageName, attributeSet);
if (desc != null) {
map.put(desc.type, new AuthenticatorInfo(desc, info.serviceInfo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例2: generateServicesMap
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private void generateServicesMap(List<ResolveInfo> services, Map<String, AuthenticatorInfo> map,
IAccountParser accountParser) {
for (ResolveInfo info : services) {
XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo,
AccountManager.AUTHENTICATOR_META_DATA_NAME);
if (parser != null) {
try {
AttributeSet attributeSet = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
// Nothing to do
}
if (AccountManager.AUTHENTICATOR_ATTRIBUTES_NAME.equals(parser.getName())) {
AuthenticatorDescription desc = parseAuthenticatorDescription(
accountParser.getResources(mContext, info.serviceInfo.applicationInfo),
info.serviceInfo.packageName, attributeSet);
if (desc != null) {
map.put(desc.type, new AuthenticatorInfo(desc, info.serviceInfo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例3: onAccountsUpdated
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
/**
* Updates account list spinner when the list of Accounts on the system changes. Satisfies
* OnAccountsUpdateListener implementation.
*/
public void onAccountsUpdated(Account[] a) {
Log.i(TAG, "Account list update detected");
// Clear out any old data to prevent duplicates
mAccounts.clear();
// Get account data from system
AuthenticatorDescription[] accountTypes = AccountManager.get(this).getAuthenticatorTypes();
// Populate tables
for (int i = 0; i < a.length; i++) {
// The user may have multiple accounts with the same name, so we need to construct a
// meaningful display name for each.
String systemAccountType = a[i].type;
AuthenticatorDescription ad = getAuthenticatorDescription(systemAccountType,
accountTypes);
AccountData data = new AccountData(a[i].name, ad);
mAccounts.add(data);
}
// Update the account spinner
mAccountAdapter.notifyDataSetChanged();
}
示例4: parseAuthenticatorDescription
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
AttributeSet attributeSet) {
TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
try {
String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
if (TextUtils.isEmpty(accountType)) {
return null;
}
return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
customTokens);
} finally {
array.recycle();
}
}
示例5: getReleventAccountTypes
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
/**
* Return a set of account types specified by the intent as well as supported by the
* AccountManager.
*/
private Set<String> getReleventAccountTypes(final Intent intent) {
// An account type is relevant iff it is allowed by the caller and supported by the account
// manager.
Set<String> setOfRelevantAccountTypes;
final String[] allowedAccountTypes =
intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
AuthenticatorDescription[] descs = VAccountManager.get().getAuthenticatorTypes();
Set<String> supportedAccountTypes = new HashSet<String>(descs.length);
for (AuthenticatorDescription desc : descs) {
supportedAccountTypes.add(desc.type);
}
if (allowedAccountTypes != null) {
setOfRelevantAccountTypes = new HashSet<>();
Collections.addAll(setOfRelevantAccountTypes, allowedAccountTypes);
setOfRelevantAccountTypes.retainAll(supportedAccountTypes);
} else {
setOfRelevantAccountTypes = supportedAccountTypes;
}
return setOfRelevantAccountTypes;
}
示例6: buildTypeToAuthDescriptionMap
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private void buildTypeToAuthDescriptionMap() {
for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) {
String name = null;
Drawable icon = null;
try {
Resources res = VirtualCore.get().getResources(desc.packageName);
icon = res.getDrawable(desc.iconId);
final CharSequence sequence = res.getText(desc.labelId);
name = sequence.toString();
name = sequence.toString();
} catch (Resources.NotFoundException e) {
// Nothing we can do much here, just log
VLog.w(TAG, "No icon resource for account type " + desc.type);
}
AuthInfo authInfo = new AuthInfo(desc, name, icon);
mTypeToAuthenticatorInfo.put(desc.type, authInfo);
}
}
示例7: parseAuthenticatorDescription
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
AttributeSet attributeSet) {
TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
try {
String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
if (TextUtils.isEmpty(accountType)) {
return null;
}
return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
customTokens);
} finally {
array.recycle();
}
}
示例8: parseAuthenticatorDescription
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
AttributeSet attributeSet) {
TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
try {
String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
if (TextUtils.isEmpty(accountType)) {
return null;
}
return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
customTokens);
} finally {
array.recycle();
}
}
示例9: accountToReadableString
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
public static String accountToReadableString(Context context, Account account, boolean detailed) {
PackageManager pm = context.getPackageManager();
String result = null;
for (AuthenticatorDescription d: AccountManager.get(context).getAuthenticatorTypes()) {
if (account.type.equals(d.type)) {
try {
result = pm.getResourcesForApplication(d.packageName).getString(d.labelId);
} catch (Exception e) {
if (DEBUG) {
Log.i(LOG_TAG, "accountToReadableString() got exception: "
+ e.getMessage());
}
}
break;
}
}
if (TextUtils.isEmpty(result)) {
result = account.type;
} else if (detailed) {
result = context.getString(R.string.sync_account_detailed, result, account.type);
}
return context.getString(R.string.sync_account, account.name, result);
}
示例10: onAccountsUpdated
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
/**
* Updates account list spinner when the list of Accounts on the system changes. Satisfies OnAccountsUpdateListener implementation.
*
* @param accounts
*/
@Override
public void onAccountsUpdated(Account[] accounts) {
LogUtils.i("Account list update detected");
// Clear out any old data to prevent duplicates.
mAccounts.clear();
// Get account data from system
AuthenticatorDescription[] accountTypes = AccountManager.get(getContext()).getAuthenticatorTypes();
// Populate tables
for (int i = 0; i < accounts.length; i++) {
// The user may have multiple accounts with the same name, so we need to construct a meaningful display name for each.
String systemAccountType = accounts[i].type;
AuthenticatorDescription ad = getAuthenticatorDescription(systemAccountType, accountTypes);
AccountData data = new AccountData(accounts[i].name, ad);
mAccounts.add(data);
}
// Update the account spinner
mAccountAdapter.notifyDataSetChanged();
}
示例11: AccountData
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
public AccountData(String name, AuthenticatorDescription description) {
mName = name;
if (null != description) {
mType = description.type;
// The type string is stored in a resource, so we need to convert it into something human readable.
String packageName = description.packageName;
PackageManager pm = getActivity().getPackageManager();
if (description.labelId != 0) {
mTypeLabel = pm.getText(packageName, description.labelId, null);
if (null == mTypeLabel) {
throw new IllegalArgumentException("LabelID provided, but label not fount");
}
} else {
mTypeLabel = "";
}
if (description.iconId != 0) {
mIcon = pm.getDrawable(packageName, description.iconId, null);
if (null == mIcon) {
throw new IllegalArgumentException("IconID provided, but drawable not found");
}
} else {
mIcon = getResources().getDrawable(android.R.drawable.sym_def_app_icon);
}
}
}
示例12: onAccountsUpdated
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
/**
* Updates account list spinner when the list of Accounts on the system
* changes. Satisfies OnAccountsUpdateListener implementation.
*/
public void onAccountsUpdated(Account[] a) {
Log.i("Account list update detected");
// Clear out any old data to prevent duplicates
mAccounts.clear();
// Get account data from system
AuthenticatorDescription[] accountTypes = AccountManager.get(this)
.getAuthenticatorTypes();
// Populate tables
for (int i = 0; i < a.length; i++) {
// The user may have multiple accounts with the same name, so we
// need to construct a
// meaningful display name for each.
String systemAccountType = a[i].type;
AuthenticatorDescription ad = getAuthenticatorDescription(
systemAccountType, accountTypes);
AccountData data = new AccountData(a[i].name, ad);
mAccounts.add(data);
}
// Update the account spinner
mAccountAdapter.notifyDataSetChanged();
}
示例13: XmlModel
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
public XmlModel(Context context, AuthenticatorDescription authenticator) throws ModelInflaterException
{
super(context, authenticator.type);
mPackageName = authenticator.packageName;
mPackageManager = context.getPackageManager();
try
{
mModelContext = context.createPackageContext(authenticator.packageName, 0);
AccountManager am = AccountManager.get(context);
mAccountLabel = mModelContext.getString(authenticator.labelId);
}
catch (NameNotFoundException e)
{
throw new ModelInflaterException("No model definition found for package " + mPackageName);
}
}
示例14: getReleventAccountTypes
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
/**
* Return a set of account types speficied by the intent as well as supported by the
* AccountManager.
*/
private Set<String> getReleventAccountTypes(final Intent intent) {
// An account type is relevant iff it is allowed by the caller and supported by the account
// manager.
Set<String> setOfRelevantAccountTypes = null;
final String[] allowedAccountTypes =
intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY);
if (allowedAccountTypes != null) {
setOfRelevantAccountTypes = Sets.newHashSet(allowedAccountTypes);
AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
Set<String> supportedAccountTypes = new HashSet<String>(descs.length);
for (AuthenticatorDescription desc : descs) {
supportedAccountTypes.add(desc.type);
}
setOfRelevantAccountTypes.retainAll(supportedAccountTypes);
}
return setOfRelevantAccountTypes;
}
示例15: hasLetvAuthenticator
import android.accounts.AuthenticatorDescription; //导入依赖的package包/类
private boolean hasLetvAuthenticator() {
for (AuthenticatorDescription authenticatorType : this.accountManager.getAuthenticatorTypes()) {
if (this.ACCOUNT_TYPE.equals(authenticatorType.type)) {
return true;
}
}
return false;
}