List of usage examples for android.accounts AccountManager getUserData
public String getUserData(final Account account, final String key)
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.ItemListActivity.java
@Override protected void onResume() { super.onResume(); if (AppUtils.getDefaults(ConstantKeys.FROMLOGIN, this).equalsIgnoreCase("true")) { finish();/*w ww.ja va2 s . co m*/ } AppUtils.CancelNotification(getApplicationContext()); try { Account ac = AccountUtils.getAccount(this, true); if (ac != null) { account = ac; AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); String userName = am.getUserData(ac, JsonKeys.NAME) + " " + am.getUserData(ac, JsonKeys.SURNAME); getActionBar().setSubtitle(userName); } } catch (Exception e) { Log.d("Error trying to get user data", e.toString()); } // registering our receiver registerReceiver(mGCMReceiver, gcmFilter); refreshList(); }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java
protected void callVideo() { if ((mGroup == null) && (mUser == null)) { log.warn("Group and user not set, cannot call"); return;/*from w ww. j a v a 2 s.c o m*/ } String userVideoName = ""; if ((mGroup != null) || (mUser != null)) { Account ac = AccountUtils.getAccount(messagesActivity, true); if (ac != null) { account = ac; AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); userVideoName = am.getUserData(ac, JsonKeys.NAME) + am.getUserData(ac, JsonKeys.SURNAME); getActionBar().setSubtitle(userName); } Intent i = new Intent(messagesActivity, RoomActivity.class); i.putExtra(RoomActivity.EXTRA_ROOM_NAME, timeline.getParty().getId().toString()); i.putExtra(RoomActivity.EXTRA_USER_NAME, userVideoName); messagesActivity.startActivity(i); } else { return; } }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java
@Override protected void onResume() { super.onResume(); registerReceivers();/*from ww w . j av a 2s . c om*/ if (AppUtils.getDefaults(ConstantKeys.FROMLOGIN, messagesActivity).equalsIgnoreCase("true")) { finish(); } AppUtils.CancelNotification(getApplicationContext()); Account ac = AccountUtils.getAccount(messagesActivity, true); if (ac != null) { account = ac; AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); userName = am.getUserData(ac, JsonKeys.NAME) + " " + am.getUserData(ac, JsonKeys.SURNAME); getActionBar().setSubtitle(userName); } // First we need to take the group from this timeline if (timeline.getParty().getType().equals(ConstantKeys.GROUP)) { ArrayList<GroupObject> groups = DataBasesAccess.getInstance(getApplicationContext()) .GroupsDataBase(DataBasesAccess.READ, null); for (GroupObject group : groups) { if (group.getGroupId().equals(String.valueOf(timeline.getParty().getId()))) { mGroup = group; break; } } } else if (timeline.getParty().getType().equals(ConstantKeys.USER)) { ArrayList<UserObject> users = DataBasesAccess.getInstance(getApplicationContext()) .UsersDataBase(DataBasesAccess.READ, null); for (UserObject user : users) { if (user.getId().toString().equals(String.valueOf(timeline.getParty().getId()))) { mUser = user; break; } } } DataBasesAccess.getInstance(getApplicationContext()).TimelinesDataBaseWriteNewMessageFalse(timeline); doRefresh(!fromOnCreate); updateTimeline(); }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java
protected void setupMsgToBeShown(MessageObject mo) { if (mo.getContent().getContentSize() > 0) { mo.setHumanSize(AppUtils.humanReadableByteCount(mo.getContent().getContentSize(), true)); }// w w w . j a va2s .c o m Account ac = AccountUtils.getAccount(messagesActivity, false); if (ac == null) { log.warn("Cannot setup messages to be shown. Account is null"); return; } AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); String userId = am.getUserData(ac, JsonKeys.ID_STORED); String fromId = String.valueOf(mo.getFrom().getId()); if (userId.equals(fromId)) { mo.setBackgroundColor(R.drawable.bg_right); mo.setMarginLeft(getResources().getDimensionPixelSize(R.dimen.message_margin)); mo.setMarginRight(0); mo.setMessageFromSize(0); mo.setMessageStatusSize(getResources().getDimensionPixelSize(R.dimen.message_status_icon)); mo.setAlignLayout(RelativeLayout.ALIGN_RIGHT); mo.setAvatarSize(0); mo.getFrom().setName(ConstantKeys.STRING_DEFAULT); mo.getFrom().setSurname(ConstantKeys.STRING_DEFAULT); mo.setCanCall(null); } else { mo.setMessageStatusSize(0); mo.setBackgroundColor(R.drawable.bg_left); mo.setMarginLeft(0); mo.setMarginRight(getResources().getDimensionPixelSize(R.dimen.message_margin)); mo.setMessageFromSize(getResources().getDimensionPixelSize(R.dimen.message_from)); mo.setAlignLayout(RelativeLayout.ALIGN_LEFT); mo.setAvatarSize(getResources().getDimensionPixelSize(R.dimen.message_avatar)); mo.setCanCall(null); } if (mo.getContent().getId() != 0) { mo.setMediaThumbnailSize(getResources().getDimensionPixelSize(R.dimen.media_thumnail)); mo.setMediaCancelButtonSize(0); mo.setMediaTypeIconSize(getResources().getDimensionPixelSize(R.dimen.media_type_icon)); if (mo.getContent().getContentType().contains(ConstantKeys.IMAGE)) { mo.setMediaTypeIconResource(android.R.drawable.ic_menu_camera); } else if (mo.getContent().getContentType().contains(ConstantKeys.VIDEO)) { mo.setMediaTypeIconResource(android.R.drawable.ic_media_play); } else { mo.setMediaTypeIconResource(android.R.drawable.ic_menu_gallery); } } else { mo.setMediaThumbnailSize(0); mo.setMediaCancelButtonSize(0); mo.setMediaTypeIconSize(0); // we need something to load, but it's not gonna be shown mo.setMediaTypeIconResource(android.R.drawable.ic_menu_gallery); } }
From source file:edu.mit.mobile.android.locast.net.NetworkClient.java
protected synchronized void loadFromExistingAccount(Account account) { if (account == null) { throw new IllegalArgumentException("must specify account"); }// w w w.j a v a 2s . com String baseUrlString; final AccountManager am = AccountManager.get(mContext); baseUrlString = am.getUserData(account, AuthenticationService.USERDATA_LOCAST_API_URL); if (baseUrlString == null) { Log.w(TAG, "loading base URL from preferences instead of account metadata"); baseUrlString = getBaseUrlFromPreferences(mContext); // if it's null in the userdata, then it must be an account from before this feature // was added. // Store for later use. am.setUserData(account, AuthenticationService.USERDATA_LOCAST_API_URL, baseUrlString); } try { setBaseUrl(baseUrlString); setCredentialsFromAccount(account); } catch (final MalformedURLException e) { Log.e(TAG, e.getLocalizedMessage(), e); } }
From source file:liqui.droid.activity.Base.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); switch (requestCode) { case (42): { // open accounts if (resultCode == Activity.RESULT_OK) { Account account = intent.getParcelableExtra("account"); AccountManager am = AccountManager.get(this); Log.d("XXX", "Selected account: " + account); Uri LQFBUri = Uri.parse("content://liqui.droid.system/lqfbs"); // clear all last active entries ContentValues valuesActive = new ContentValues(); valuesActive.put(DBSystem.TableLQFBs.COLUMN_LAST_ACTIVE, 0); getContentResolver().update(LQFBUri, valuesActive, null, null); // save last active entry and member + session values ContentValues values = new ContentValues(); values.put(DBSystem.TableLQFBs.COLUMN_MEMBER_ID, am.getUserData(account, Constants.Account.MEMBER_ID)); values.put(DBSystem.TableLQFBs.COLUMN_SESSION_KEY, am.getUserData(account, Constants.Account.SESSION_KEY)); values.put(DBSystem.TableLQFBs.COLUMN_LAST_ACTIVE, 1); values.put(DBSystem.TableLQFBs.COLUMN_META_CACHED, System.currentTimeMillis()); getContentResolver().update(LQFBUri, values, DBSystem.TableLQFBs.COLUMN_NAME + " = ?", new String[] { am.getUserData(account, Constants.Account.API_NAME) }); // start member activity Bundle extras = new Bundle(); extras.putString(Constants.Account.API_NAME, am.getUserData(account, Constants.Account.API_NAME)); extras.putString(Constants.Account.API_URL, am.getUserData(account, Constants.Account.API_URL)); extras.putString(Constants.Account.MEMBER_ID, am.getUserData(account, Constants.Account.MEMBER_ID)); extras.putString(Constants.Account.SESSION_KEY, am.getUserData(account, Constants.Account.SESSION_KEY)); Intent i = new Intent().setClass(getApplicationContext(), MemberActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtras(extras);/* www. j ava 2 s .co m*/ startActivity(i); } break; } } }
From source file:org.tigase.messenger.phone.pro.service.XMPPService.java
private final void updateJaxmppInstances() { final HashSet<BareJID> accountsJids = new HashSet<BareJID>(); for (JaxmppCore jaxmpp : multiJaxmpp.get()) { accountsJids.add(jaxmpp.getSessionObject().getUserBareJid()); }/*from w w w .ja va2 s .c o m*/ final AccountManager am = AccountManager.get(this); for (Account account : am.getAccountsByType(Authenticator.ACCOUNT_TYPE)) { BareJID accountJid = BareJID.bareJIDInstance(account.name); Jaxmpp jaxmpp = multiJaxmpp.get(accountJid); if (jaxmpp == null) { jaxmpp = createJaxmpp(accountJid, account.hashCode()); multiJaxmpp.add(jaxmpp); } // workaround for unknown certificate error jaxmpp.getSessionObject().setProperty("jaxmpp#ThrowedException", null); String password = am.getPassword(account); String nickname = am.getUserData(account, AccountsConstants.FIELD_NICKNAME); String hostname = am.getUserData(account, AccountsConstants.FIELD_HOSTNAME); String resource = am.getUserData(account, AccountsConstants.FIELD_RESOURCE); hostname = hostname == null ? null : hostname.trim(); jaxmpp.getSessionObject().setUserProperty(SessionObject.PASSWORD, password); jaxmpp.getSessionObject().setUserProperty(SessionObject.NICKNAME, nickname); if (hostname != null && TextUtils.isEmpty(hostname)) hostname = null; // sessionObject.setUserProperty(SessionObject.DOMAIN_NAME, // hostname); if (TextUtils.isEmpty(resource)) resource = null; jaxmpp.getSessionObject().setUserProperty(SessionObject.RESOURCE, resource); MobileModeFeature.updateSettings(account, jaxmpp, this); boolean disabled = !Boolean.parseBoolean(am.getUserData(account, AccountsConstants.FIELD_ACTIVE)); jaxmpp.getSessionObject().setUserProperty("CC:DISABLED", disabled); if (disabled) { if (jaxmpp.isConnected()) { this.disconnectJaxmpp(jaxmpp, true); } } else { if (!jaxmpp.isConnected()) { this.connectJaxmpp(jaxmpp, 1L); } } accountsJids.remove(accountJid); } for (BareJID accountJid : accountsJids) { final Jaxmpp jaxmpp = multiJaxmpp.get(accountJid); if (jaxmpp != null) { multiJaxmpp.remove(jaxmpp); (new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { jaxmpp.disconnect(); // clear presences for account? // app.clearPresences(jaxmpp.getSessionObject(), // false); // is this needed any more?? // JaxmppService.this.rosterProvider.resetStatus(jaxmpp.getSessionObject()); } catch (Exception ex) { Log.e(TAG, "Can't disconnect", ex); } return null; } }).execute(); } } dataRemover.removeUnusedData(this); }