List of usage examples for android.accounts AccountManager setUserData
public void setUserData(final Account account, final String key, final String value)
From source file:org.klnusbaum.udj.network.PlayerCommService.java
private void doLoginFail(AccountManager am, Account account, PlayerJoinError error) { am.setUserData(account, Constants.PLAYER_STATE_DATA, String.valueOf(Constants.PLAYER_JOIN_FAILED)); am.setUserData(account, Constants.PLAYER_JOIN_ERROR, error.toString()); Intent playerJoinFailedIntent = new Intent(Constants.PLAYER_JOIN_FAILED_ACTION); Log.d(TAG, "Sending player join failure broadcast"); sendBroadcast(playerJoinFailedIntent); }
From source file:org.klnusbaum.udj.network.EventCommService.java
private void setEventData(Intent intent, AccountManager am, Account account) { am.setUserData(account, Constants.EVENT_NAME_DATA, intent.getStringExtra(Constants.EVENT_NAME_EXTRA)); am.setUserData(account, Constants.EVENT_HOSTNAME_DATA, intent.getStringExtra(Constants.EVENT_HOSTNAME_EXTRA)); am.setUserData(account, Constants.EVENT_HOST_ID_DATA, String.valueOf(intent.getLongExtra(Constants.EVENT_HOST_ID_EXTRA, -1))); am.setUserData(account, Constants.EVENT_LAT_DATA, String.valueOf(intent.getDoubleExtra(Constants.EVENT_LAT_EXTRA, -100.0))); am.setUserData(account, Constants.EVENT_LONG_DATA, String.valueOf(intent.getDoubleExtra(Constants.EVENT_LONG_EXTRA, -100.0))); }
From source file:org.klnusbaum.udj.network.EventCommService.java
private void setNotInEvent(Account account) { AccountManager am = AccountManager.get(this); am.setUserData(account, Constants.LAST_EVENT_ID_DATA, String.valueOf(Constants.NO_EVENT_ID)); am.setUserData(account, Constants.EVENT_STATE_DATA, String.valueOf(Constants.NOT_IN_EVENT)); }
From source file:org.klnusbaum.udj.network.EventCommService.java
private void doLoginFail(AccountManager am, Account account, EventJoinError error) { am.setUserData(account, Constants.EVENT_JOIN_ERROR, error.toString()); Intent eventJoinFailedIntent = new Intent(Constants.EVENT_JOIN_FAILED_ACTION); Log.d(TAG, "Sending event join failure broadcast"); sendBroadcast(eventJoinFailedIntent); }
From source file:org.klnusbaum.udj.network.PlayerCommService.java
private void setLoggedInToPlayer(Intent joinPlayerIntent, AccountManager am, Account account, String playerId) { setPlayerData(joinPlayerIntent, am, account); am.setUserData(account, Constants.LAST_PLAYER_ID_DATA, playerId); am.setUserData(account, Constants.PLAYER_STATE_DATA, String.valueOf(Constants.IN_PLAYER)); Log.d(TAG, "Sending joined player broadcast"); Intent playerJoinedBroadcast = new Intent(Constants.JOINED_PLAYER_ACTION); sendBroadcast(playerJoinedBroadcast); }
From source file:com.ntsync.android.sync.client.ClientKeyHelper.java
/** * //from www. j a v a 2s .c om * @param account * @param accountManager * @param keyPwd * Password for Key * @param salt * @param existingSalt * @param pwdCheck * null for new Key otherwise used to Check if it is the right * Password. * @return * @throws InvalidKeyException * @throws UnsupportedEncodingException */ public static SecretKey createKey(Account account, AccountManager accountManager, String keyPwd, byte[] salt, boolean existingSalt, byte[] pwdCheck) throws InvalidKeyException, UnsupportedEncodingException { KeyGenerator keyGen = new KeyGenerator(); SecretKey skey = keyGen.generateKey(keyPwd, salt); byte[] raw = skey.getEncoded(); String keyValue = Base64.encodeToString(raw, Base64.DEFAULT); String saltStr = Base64.encodeToString(salt, Base64.DEFAULT); assert (existingSalt ? pwdCheck != null : true); byte[] check = pwdCheck; if (existingSalt && pwdCheck != null) { // Validate new Passwort validateKey(check, skey); } else if (!existingSalt) { check = createPwdCheck(skey); } String pwdCheckStr = check != null ? Base64.encodeToString(check, Base64.DEFAULT) : null; accountManager.setUserData(account, PRIVATE_KEY_SALTSAVED, existingSalt ? "true" : "false"); accountManager.setUserData(account, PRIVATE_KEYSALT, saltStr); accountManager.setUserData(account, PRIVATE_PWDCHECK, pwdCheckStr); accountManager.setUserData(account, PRIVATE_PWD, keyPwd); accountManager.setUserData(account, PRIVATE_KEY, keyValue); return skey; }
From source file:org.klnusbaum.udj.PlayerActivity.java
private void changePlaybackMenuOption(int newPlaybackState) { AccountManager am = AccountManager.get(this); am.setUserData(account, Constants.PLAYBACK_STATE_DATA, String.valueOf(newPlaybackState)); invalidateOptionsMenu();//ww w . j av a 2 s .c o m }
From source file:org.andstatus.app.account.AccountData.java
/** * @param result /*from w w w. ja v a2s .co m*/ * @return true if Android account changed */ void saveDataToAccount(MyContext myContext, Account androidAccount, SaveResult result) { AccountData oldData = fromAndroidAccount(myContext, androidAccount); result.changed = !this.equals(oldData); if (result.changed) { long syncFrequencySeconds = getDataLong(MyPreferences.KEY_SYNC_FREQUENCY_SECONDS, 0); if (syncFrequencySeconds > 0 && syncFrequencySeconds != getSyncFrequencySeconds(androidAccount)) { result.changed = true; setSyncFrequencySeconds(androidAccount, syncFrequencySeconds); } boolean isSyncable = getDataBoolean(MyAccount.KEY_IS_SYNCABLE, true); if (isSyncable != (ContentResolver.getIsSyncable(androidAccount, MyProvider.AUTHORITY) != 0)) { ContentResolver.setIsSyncable(androidAccount, MyProvider.AUTHORITY, isSyncable ? 1 : 0); } boolean syncAutomatically = getDataBoolean(MyAccount.KEY_SYNC_AUTOMATICALLY, true); if (syncAutomatically != ContentResolver.getSyncAutomatically(androidAccount, MyProvider.AUTHORITY)) { // We need to preserve sync on/off during backup/restore. // don't know about "network tickles"... See: // http://stackoverflow.com/questions/5013254/what-is-a-network-tickle-and-how-to-i-go-about-sending-one ContentResolver.setSyncAutomatically(androidAccount, MyProvider.AUTHORITY, syncAutomatically); } android.accounts.AccountManager am = AccountManager.get(myContext.context()); am.setUserData(androidAccount, KEY_ACCOUNT, toJsonString()); result.savedToAccountManager = true; } result.success = true; }
From source file:com.activiti.android.app.fragments.settings.AccountSettingsFragment.java
@Override public void onTextEdited(int id, String newValue) { Account androidAccount = ActivitiAccountManager.getInstance(getActivity()).getAndroidAccount(accountId); AccountManager manager = AccountManager.get(getActivity()); manager.setUserData(androidAccount, ActivitiAccount.ACCOUNT_TITLE, newValue); account = ActivitiAccountManager.getInstance(getActivity()).getByAccountId(accountId); }
From source file:com.activiti.android.app.fragments.settings.AccountSettingsFragment.java
@Override public void onTextClear(int valueId) { Account androidAccount = ActivitiAccountManager.getInstance(getActivity()).getAndroidAccount(accountId); AccountManager manager = AccountManager.get(getActivity()); manager.setUserData(androidAccount, ActivitiAccount.ACCOUNT_TITLE, "Activiti Server"); account = ActivitiAccountManager.getInstance(getActivity()).getByAccountId(accountId); }