List of usage examples for android.accounts AccountManager KEY_ACCOUNT_NAME
String KEY_ACCOUNT_NAME
To view the source code for android.accounts AccountManager KEY_ACCOUNT_NAME.
Click Source Link
From source file:cl.chileagil.agileday2012.fragment.MainFragment.java
private void chooseAccount() { accountManager.getAccountManager().getAuthTokenByFeatures(GoogleAccountManager.ACCOUNT_TYPE, AUTH_TOKEN_TYPE, null, MainFragment.this, null, null, new AccountManagerCallback<Bundle>() { public void run(AccountManagerFuture<Bundle> future) { Bundle bundle;/* w ww. j a v a2 s . c o m*/ try { bundle = future.getResult(); setAccountName(bundle.getString(AccountManager.KEY_ACCOUNT_NAME)); setAuthToken(bundle.getString(AccountManager.KEY_AUTHTOKEN)); onAuthToken(); } catch (OperationCanceledException e) { // user canceled } catch (AuthenticatorException e) { Log.e(TAG, e.getMessage(), e); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } } }, null); }
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java
/** * Called when response is received from the server for authentication * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. We store the * authToken that's returned from the server as the 'password' for this * account - so we're never storing the user's actual password locally. * * @param result the confirmCredentials result. *///from w ww . j a va2s . c o m private void finishLogin(String authToken) { Log.i(TAG, "finishLogin()"); final Account account = new Account(mUsername, GMSApplication.ACCOUNT_TYPE); if (mIsUnknownAccountName) { mAccountManager.addAccountExplicitly(account, mPassword, null); // Set contacts sync for this account. ContentResolver.setIsSyncable(account, GMSProvider.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, GMSProvider.AUTHORITY, true); } else { mAccountManager.setPassword(account, mPassword); } final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, GMSApplication.ACCOUNT_TYPE); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:be.evias.cloudLogin.cloudLoginMainActivity.java
private void finishLogout(Intent intent) { String uName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); Log.d("cloudLogin", "cloudloginMainActivity/finishLogout: Account '" + uName + "' logged out."); SharedPreferences.Editor ed = mPrefs.edit(); ed.putBoolean("cloudlogin_active_account", false); ed.remove("cloudlogin_active_account_name"); ed.remove("cloudlogin_active_account_email"); ed.commit();//from ww w . j ava2s .co m setResult(RESULT_OK, intent); finish(); }
From source file:ru.orangesoftware.financisto2.activity.PreferencesActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case SELECT_DATABASE_FOLDER: String databaseBackupFolder = data.getStringExtra(FolderBrowser.PATH); MyPreferences.setDatabaseBackupFolder(this, databaseBackupFolder); setCurrentDatabaseBackupFolder(); break; case CHOOSE_ACCOUNT: if (data != null) { Bundle b = data.getExtras(); String accountName = b.getString(AccountManager.KEY_ACCOUNT_NAME); Log.d("Preferences", "Selected account: " + accountName); if (accountName != null && accountName.length() > 0) { MyPreferences.setGoogleDriveAccount(this, accountName); selectAccount();/* w w w .java 2 s .co m*/ } } break; } } }
From source file:org.voidsink.anewjkuapp.activity.KusssAuthenticatorActivity.java
private void finishLogin(Intent intent) { String accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); String accountPassword = intent.getStringExtra(PARAM_USER_PASS); String accountType = intent.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE); Log.i(TAG, "finish login to " + accountName); Account account;// ww w. j ava2 s. c o m boolean addNewAccount; final Account oldAccount = AppUtils.getAccount(this); if (oldAccount != null) { if (oldAccount.name.equals(accountName)) { account = oldAccount; addNewAccount = false; } else { AppUtils.removeAccout(mAccountManager, oldAccount); account = new Account(accountName, accountType); addNewAccount = true; } } else { account = new Account(accountName, accountType); addNewAccount = true; } if (addNewAccount) { String authtoken = intent.getStringExtra(AccountManager.KEY_AUTHTOKEN); String authtokenType = mAuthTokenType; // Creating the account on the device and setting the auth token we // got // (Not setting the auth token will cause another call to the server // to authenticate the user) mAccountManager.addAccountExplicitly(account, accountPassword, null); mAccountManager.setAuthToken(account, authtokenType, authtoken); mAccountManager.setPassword(account, accountPassword); // Turn on periodic syncing long interval = PreferenceWrapper.getSyncInterval(this) * 60 * 60; ContentResolver.addPeriodicSync(account, CalendarContractWrapper.AUTHORITY(), new Bundle(), interval); ContentResolver.addPeriodicSync(account, KusssContentContract.AUTHORITY, new Bundle(), interval); // Inform the system that this account supports sync ContentResolver.setIsSyncable(account, CalendarContractWrapper.AUTHORITY(), 1); ContentResolver.setIsSyncable(account, KusssContentContract.AUTHORITY, 1); // Inform the system that this account is eligible for auto sync // when the network is up ContentResolver.setSyncAutomatically(account, CalendarContractWrapper.AUTHORITY(), true); ContentResolver.setSyncAutomatically(account, KusssContentContract.AUTHORITY, true); // Recommend a schedule for automatic synchronization. The system // may modify this based // on other scheduled syncs and network utilization. } else { mAccountManager.setPassword(account, accountPassword); } // Kalender aktualisieren CalendarUtils.createCalendarsIfNecessary(this, account); // Sync NOW KusssAuthenticator.triggerSync(this); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.owncloud.android.ui.activity.UploadListActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FileActivity.REQUEST_CODE__UPDATE_CREDENTIALS && resultCode == RESULT_OK) { // Retry uploads of the updated account Account account = AccountUtils.getOwnCloudAccountByName(this, data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)); TransferRequester requester = new TransferRequester(); requester.retryFailedUploads(this, account, UploadResult.CREDENTIAL_ERROR, false); }//w w w . j a v a 2s . c om }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
/** * Called when response is received from the server for authentication * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. We store the * authToken that's returned from the server as the 'password' for this * account - so we're never storing the user's actual password locally. * * @param result the confirmCredentials result. *///ww w .j av a2 s.c o m private void finishLogin(ServerConnection.AuthResult authResult) { Log.i(TAG, "finishLogin()"); final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); if (mRequestNewAccount) { mAccountManager.addAccountExplicitly(account, mPassword, null); ContentResolver.setIsSyncable(account, Constants.AUTHORITY, 0); } else { mAccountManager.setPassword(account, mPassword); } mAccountManager.setUserData(account, Constants.USER_ID_DATA, authResult.userId); mAccountManager.setUserData(account, Constants.LAST_PLAYER_ID_DATA, Constants.NO_PLAYER_ID); mAccountManager.setUserData(account, Constants.PLAYER_STATE_DATA, Integer.toString(Constants.NOT_IN_PLAYER)); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE); intent.putExtra(Constants.ACCOUNT_EXTRA, account); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.meiste.tempalarm.ui.CurrentTemp.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case ACCOUNT_PICKER_REQUEST: if ((data != null) && (data.getExtras() != null)) { final String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); if (!TextUtils.isEmpty(accountName)) { Timber.d("User selected " + accountName); AccountUtils.setAccount(this, accountName); }// w w w .j a v a 2s. co m } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.google.adsensequickstart.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode == Activity.RESULT_OK) { haveGooglePlayServices();//from w w w .java 2s. c om } else { checkGooglePlayServicesAvailable(); } break; case REQUEST_AUTHORIZATION: if (resultCode == Activity.RESULT_OK) { publisherAccountId = null; status = AppStatus.GETTING_ACCOUNT_ID; refreshView(); } else { chooseDeviceAccount(); } break; case REQUEST_ACCOUNT_PICKER: if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { apiController.setAccountName(accountName); refreshView(); } } break; default: break; } }
From source file:com.beem.project.beem.ui.wizard.AccountConfigureFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SELECT_ACCOUNT_CODE && resultCode == Activity.RESULT_OK) { mSelectedAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); mSelectedAccountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE); onDeviceAccountSelected(mSelectedAccountName, mSelectedAccountType); } else if (requestCode == MANUAL_CONFIGURATION_CODE) { String login = settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, ""); String password = settings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, ""); mAccountJID.setText(login);//www.j a v a 2 s . com mAccountPassword.setText(password); } else { super.onActivityResult(requestCode, resultCode, data); } }