List of usage examples for android.accounts Account Account
public Account(@NonNull Account other, @NonNull String accessId)
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java
/** * Called when response is received from the server for confirm credentials * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. * * @param result the confirmCredentials result. *///from w ww. j av a 2s . c om private void finishConfirmCredentials(boolean result) { Log.i(TAG, "finishConfirmCredentials()"); final Account account = new Account(mUsername, GMSApplication.ACCOUNT_TYPE); mAccountManager.setPassword(account, mPassword); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.skywomantechnology.app.guildviewer.sync.GuildViewerSyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or make a new one if the * fake account doesn't exist yet./*w w w . ja v a 2s . c om*/ * * @param context * The context used to access the account service * @return a fake account. */ public static Account getSyncAccount(Context context) { // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (null == accountManager.getPassword(newAccount)) { // Add the account and account type, no password or user data // If successful, return the Account object, otherwise report an error. if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } // If you don't set android:syncable="true" in your <provider> element in the manifest, // then call context.setIsSyncable(account, AUTHORITY, 1) here. onAccountCreated(newAccount, context); } return newAccount; }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java
public static Account CreateSyncAccount(Context context) { try {//from ww w.java 2 s . c om // Create the account type and default account Account newAccount = new Account(ACCOUNT, ACCOUNT_TYPE); // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE); /* * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (accountManager.addAccountExplicitly(newAccount, null, null)) { /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call context.setIsSyncable(account, AUTHORITY, 1) * here. */ //Log.e("CreateSyncAccount","Success!"); } else { /* * The account exists or some other error occurred. Log this, report it, * or handle it internally. */ //Log.e("CreateSyncAccount","Fail!"); } return newAccount; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "CreateSyncAccount", e); return null; } }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
public static Account CreateSyncAccount(Context context) { // Create the account type and default account Account newAccount = new Account(ACCOUNT, ACCOUNT_TYPE); // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE); /*/*from w ww. ja v a 2 s .co m*/ * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (accountManager.addAccountExplicitly(newAccount, null, null)) { /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call context.setIsSyncable(account, AUTHORITY, 1) * here. */ return newAccount; } else { /* * The account exists or some other error occurred. Log this, report it, * or handle it internally. */ return null; } }
From source file:com.cerema.cloud2.lib.common.SingleSessionManager.java
@Override public void saveAllClients(Context context, String accountType) throws AccountNotFoundException, AuthenticatorException, IOException, OperationCanceledException { if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "Saving sessions... "); }/* www .j av a 2 s. c o m*/ Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator(); String accountName = null; Account account = null; while (accountNames.hasNext()) { accountName = accountNames.next(); account = new Account(accountName, accountType); AccountUtils.saveClient(mClientsWithKnownUsername.get(accountName), account, context); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "All sessions saved"); } }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
/** * Called when response is received from the server for confirm credentials * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. * * @param result the confirmCredentials result. *//*ww w. j a va 2 s. c om*/ private void finishConfirmCredentials(boolean result) { Log.i(TAG, "finishConfirmCredentials()"); final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); mAccountManager.setPassword(account, mPassword); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.android.contacts.util.AccountFilterUtil.java
/** * Start editor intent; and if filter is an account filter, we pass account info to editor so * as to create a contact in that account. *//* ww w. j a v a 2 s . c o m*/ public static void startEditorIntent(Context context, Intent src, ContactListFilter filter) { final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); intent.putExtras(src); // If we are in account view, we pass the account explicitly in order to // create contact in the account. This will prevent the default account dialog // from being displayed. if (!isAllContactsFilter(filter) && filter.accountName != null && filter.accountType != null) { final Account account = new Account(filter.accountName, filter.accountType); intent.putExtra(Intents.Insert.EXTRA_ACCOUNT, account); intent.putExtra(Intents.Insert.EXTRA_DATA_SET, filter.dataSet); } else if (isDeviceContactsFilter(filter)) { intent.putExtra(ContactEditorActivity.EXTRA_ACCOUNT_WITH_DATA_SET, filter.toAccountWithDataSet()); } try { ImplicitIntentsUtil.startActivityInApp(context, intent); } catch (ActivityNotFoundException ex) { Toast.makeText(context, R.string.missing_app, Toast.LENGTH_SHORT).show(); } }
From source file:com.ntsync.android.sync.activities.KeyPasswordActivity.java
/** * Called when KeyPassword was set./*from www. j a v a2 s.com*/ * * @param result * the confirmCredentials result. */ private void finishSetKeyPassword() { Log.i(TAG, "finishSetKeyPassword()"); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE); setResult(RESULT_OK, intent); Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); ContentResolver.requestSync(account, Constants.CONTACT_AUTHORITY, new Bundle()); // Remove notification clearNotification(account.name); finish(); }
From source file:edu.mit.mobile.android.locast.accounts.AuthenticatorActivity.java
/** * Called when response is received from the server for confirm credentials request. See * onAuthenticationResult(). Sets the AccountAuthenticatorResult which is sent back to the * caller.//from w ww. j a v a 2s.c o m * * @param the * confirmCredentials result. */ protected void finishConfirmCredentials(boolean result) { Log.i(TAG, "finishConfirmCredentials()"); final Account account = new Account(mUsername, AuthenticationService.ACCOUNT_TYPE); mAccountManager.setPassword(account, mPassword); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.murrayc.galaxyzoo.app.LoginUtils.java
/** * Add the anonymous Account.// w w w .ja v a2 s . com * * Don't call this from the main thread - use an AsyncTask, for instance. * @param context */ private static void addAnonymousAccount(final Context context) { final AccountManager accountManager = AccountManager.get(context); final Account account = new Account(ACCOUNT_NAME_ANONYMOUS, LoginUtils.ACCOUNT_TYPE); //Note that this requires the AUTHENTICATE_ACCOUNTS permission on //SDK <=22: accountManager.addAccountExplicitly(account, null, null); //In case it has not been called yet. //This has no effect the second time. Utils.initDefaultPrefs(context); //Give the new account the existing (probably default) preferences, //so the SyncAdapter can use them. //See SettingsFragment.onSharedPreferenceChanged(). copyPrefsToAccount(context, accountManager, account); //Tell the SyncAdapter to sync whenever the network is reconnected: setAutomaticAccountSync(context, account); }