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:at.mg.androidfeatures.activities.GoogleServiceTest.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_ACCOUNTPICKER: if (resultCode == RESULT_OK) { String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); AccountUtils.setAccountName(this, accountName); Log.i(accountName);//from w w w. ja va 2 s .c o m } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "This application requires a Google account.", Toast.LENGTH_SHORT).show(); finish(); } return; case REQUEST_CODE_RECOVER_PLAY_SERVICES: if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Google Play Services must be installed.", Toast.LENGTH_SHORT).show(); finish(); } return; } super.onActivityResult(requestCode, resultCode, data); }
From source file:cc.softwarefactory.lokki.android.activities.SignUpActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (data == null) { Log.e(TAG, "Get default account returned null. Nothing to do."); return;/*from w ww.ja va 2s . c o m*/ } Log.e(TAG, "onActivityResult. Data: " + data.getExtras()); super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_EMAIL && resultCode == RESULT_OK) { String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { aq.id(R.id.email).text(accountName); } } }
From source file:com.pindroid.activity.ChooseTagShortcut.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == Constants.REQUEST_CODE_ACCOUNT_CHANGE) { username = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); frag.setUsername(username);// w ww. j ava 2 s .c o m frag.refresh(); } }
From source file:be.evias.cloudLogin.cloudLoginMainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); checkConnection();/*from w w w. j a va 2 s .com*/ mAccountManager = AccountManager.get(this); mAccountName = getIntent().getStringExtra(AccountManager.KEY_ACCOUNT_NAME); mAccount = new Account(mAccountName, AccountBase.ACCOUNT_TYPE); mContext = getBaseContext(); mPrefs = mContext.getSharedPreferences("cloudlogin", Context.MODE_PRIVATE); mNavigationDrawerFragment = (FragmentNavigationDrawer) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); /* Set up the drawer. */ mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); }
From source file:com.jaspersoft.android.jaspermobile.ui.view.activity.StartupDelegate.java
private void onSignUp(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { String profileName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); Profile profile = Profile.create(profileName); mActionListener.setupNewProfile(profile); } else {// w w w . jav a2s . co m mActivity.finish(); } }
From source file:drupalfit.sample.ToolBarActivity.java
/** {@inheritDoc} */ @Override//from ww w . j a v a2 s .co m public void addAccount(String username, String password, String authToken) { String accountType = "drualfit"; String authTokenType = "drualfit"; Account account = new Account(username, accountType); Bundle userdata = null; Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, username); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType); intent.putExtra(AccountManager.KEY_AUTHTOKEN, authToken); if (TextUtils.isEmpty(password)) { boolean added = getAccountManager().addAccountExplicitly(account, password, userdata); } else { getAccountManager().setPassword(account, password); } getAccountManager().setAuthToken(account, authTokenType, authToken); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); }
From source file:com.jefftharris.passwdsafe.sync.lib.AccountChooserDlg.java
/** Handle a selected account */ private void onAccountSelected(String accountName) { Bundle args = getArguments();/*from ww w. ja va 2 s. c om*/ int requestCode = args.getInt("requestCode"); int result; Intent intent = new Intent(); if (accountName != null) { intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, accountName); result = Activity.RESULT_OK; } else { result = Activity.RESULT_CANCELED; } PendingIntent pendIntent = getActivity().createPendingResult(requestCode, intent, PendingIntent.FLAG_ONE_SHOT); try { pendIntent.send(result); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "intent send failed", e); } }
From source file:com.afwsamples.testdpc.AddAccountActivity.java
private void addAccount(String accountName) { AccountManager accountManager = AccountManager.get(this); Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(accountName)) { bundle.putString(AccountManager.KEY_ACCOUNT_NAME, accountName); }//from ww w . java2s . co m accountManager.addAccount(GOOGLE_ACCOUNT_TYPE, null, null, bundle, this, accountManagerFuture -> { try { Bundle result = accountManagerFuture.getResult(); String accountNameAdded = result.getString(AccountManager.KEY_ACCOUNT_NAME); Log.d(TAG, "addAccount - accountNameAdded: " + accountNameAdded); if (mNextActivityIntent != null) { startActivity(mNextActivityIntent); } finish(); } catch (OperationCanceledException | AuthenticatorException | IOException e) { Log.e(TAG, "addAccount - failed", e); Toast.makeText(AddAccountActivity.this, R.string.fail_to_add_account, Toast.LENGTH_LONG).show(); } }, null); }
From source file:org.tbrt.aemanager.AeManagerMenu.java
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (requestCode == AE_ACCT_REQUEST && resultCode == RESULT_OK) { String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); Toast.makeText(getApplicationContext(), "USE ACCOUNT [" + accountName + "]", Toast.LENGTH_SHORT).show(); new getAndUseAuthTokenInAsyncTask().execute(accountName); }/* w ww . j a v a 2s . c o m*/ }
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticator.java
@Override public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { Log.d(TAG, "Get Auth Token"); // If the caller requested an authToken type we don't support, then // return an error if (!authTokenType.equals(GMSApplication.AUTHTOKEN_TYPE)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType"); return result; }/* ww w. j a va 2s.c o m*/ // Extract the username and password from the Account Manager, and ask // the server for an appropriate AuthToken. final String password = AccountManager.get(mContext).getPassword(account); if (!TextUtils.isEmpty(password)) { try { final String authToken = NetworkUtilities.authenticate(account.name, password); if (!TextUtils.isEmpty(authToken)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, GMSApplication.ACCOUNT_TYPE); result.putString(AccountManager.KEY_AUTHTOKEN, authToken); return result; } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } // If we get here, then we couldn't access the user's password - so we // need to re-prompt them for their credentials. We do that by creating // an intent to display our AuthenticatorActivity panel. final Intent intent = new Intent(mContext, GMSAuthenticatorActivity.class); intent.putExtra(GMSAuthenticatorActivity.PARAM_USERNAME, account.name); intent.putExtra(GMSAuthenticatorActivity.PARAM_AUTHTOKEN_TYPE, authTokenType); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }