List of usage examples for android.accounts AccountManager KEY_BOOLEAN_RESULT
String KEY_BOOLEAN_RESULT
To view the source code for android.accounts AccountManager KEY_BOOLEAN_RESULT.
Click Source Link
From source file:org.ohmage.authenticator.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. * // w ww.j ava 2 s . co m * @param the confirmCredentials result. */ protected void finishConfirmCredentials(boolean result) { Log.v(TAG, "finishConfirmCredentials()"); final Account account = new Account(mUsername, OhmageApplication.ACCOUNT_TYPE); mAccountManager.setPassword(account, mPassword); if (mAuthtokenType != null && mAuthtokenType.equals(OhmageApplication.AUTHTOKEN_TYPE)) { mAccountManager.setAuthToken(account, mAuthtokenType, mHashedPassword); } final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.sefford.beauthentic.activities.LoginActivity.java
void createGoogleAccount(final GoogleSignInAccount acct) { final Account account = new Account(acct.getDisplayName(), AuthenticAuthenticator.ACCOUNT_TYPE); final AccountManager am = AccountManager.get(this); final Bundle data = new Bundle(); data.putInt(AuthenticAuthenticator.EXTRA_TYPE, AuthenticAuthenticator.Type.GOOGLE.ordinal()); data.putString(AccountManager.KEY_ACCOUNT_NAME, acct.getDisplayName()); data.putString(AccountManager.KEY_AUTHTOKEN, acct.getIdToken()); am.confirmCredentials(account, data, null, new AccountManagerCallback<Bundle>() { @Override// w w w . j ava 2 s . c om public void run(AccountManagerFuture<Bundle> future) { try { final Bundle result = future.getResult(); if (result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) { Sessions.addAccount(am, account, "", Bundle.EMPTY); am.setAuthToken(account, AuthenticAuthenticator.AUTHTOKEN_TYPE, result.getString(AccountManager.KEY_AUTHTOKEN)); am.setUserData(account, AuthenticAuthenticator.EXTRA_TYPE, Integer.toString(AuthenticAuthenticator.Type.GOOGLE.ordinal())); notifyLoginToGCM(AuthenticAuthenticator.Type.GOOGLE.ordinal(), account.name, "", result.getString(AccountManager.KEY_AUTHTOKEN)); googleApi.saveCredential(new Credential.Builder(acct.getEmail()) .setAccountType(IdentityProviders.GOOGLE).setName(acct.getDisplayName()) .setProfilePictureUri(acct.getPhotoUrl()).build(), new SmartlockCredentialCallback()); } } catch (OperationCanceledException e) { Snackbar.make(vLoginForm, R.string.error_operation_cancelled, Snackbar.LENGTH_LONG).show(); } catch (IOException e) { Snackbar.make(vLoginForm, R.string.error_not_connected_to_internet, Snackbar.LENGTH_LONG) .show(); } catch (AuthenticatorException e) { Snackbar.make(vLoginForm, R.string.error_invalid_credentials, Snackbar.LENGTH_LONG).show(); } } }, null); }
From source file:at.bitfire.davdroid.ui.AccountActivity.java
private void deleteAccount() { AccountManager accountManager = AccountManager.get(this); if (Build.VERSION.SDK_INT >= 22) accountManager.removeAccount(account, this, new AccountManagerCallback<Bundle>() { @Override/*from ww w . j a v a 2 s . c om*/ public void run(AccountManagerFuture<Bundle> future) { try { if (future.getResult().getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) finish(); } catch (OperationCanceledException | IOException | AuthenticatorException e) { App.log.log(Level.SEVERE, "Couldn't remove account", e); } } }, null); else accountManager.removeAccount(account, new AccountManagerCallback<Boolean>() { @Override public void run(AccountManagerFuture<Boolean> future) { try { if (future.getResult()) finish(); } catch (OperationCanceledException | IOException | AuthenticatorException e) { App.log.log(Level.SEVERE, "Couldn't remove account", e); } } }, null); }