当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticatorDescription类代码示例

本文整理汇总了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();
			}
		}
	}
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:27,代码来源:VAccountManagerService.java

示例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();
			}
		}
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:27,代码来源:VAccountManagerService.java

示例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();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:27,代码来源:ContactAdder.java

示例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();
	}
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:20,代码来源:VAccountManagerService.java

示例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;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:25,代码来源:ChooseTypeAndAccountActivity.java

示例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);
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:19,代码来源:ChooseAccountTypeActivity.java

示例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();
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:20,代码来源:VAccountManagerService.java

示例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();
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:20,代码来源:VAccountManagerService.java

示例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);
}
 
开发者ID:SpiritCroc,项目名称:SyncSettings,代码行数:24,代码来源:Util.java

示例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();
}
 
开发者ID:BruceHurrican,项目名称:asstudydemo,代码行数:26,代码来源:ContactAdderFragment.java

示例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);
        }
    }
}
 
开发者ID:BruceHurrican,项目名称:asstudydemo,代码行数:27,代码来源:ContactAdderFragment.java

示例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();
}
 
开发者ID:dmvstar,项目名称:kidsdialer,代码行数:29,代码来源:ContactAdderActivity.java

示例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);
    }

}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:18,代码来源:XmlModel.java

示例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;
}
 
开发者ID:frakbot,项目名称:Android-AccountChooser,代码行数:22,代码来源:ChooseTypeAndAccountActivity.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:LogonManager.java


注:本文中的android.accounts.AuthenticatorDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。