List of usage examples for android.content ContentValues toString
@Override
public String toString()
From source file:com.android.mail.compose.ComposeActivity.java
private static void launch(Context context, Account account, Message message, int action, String toAddress, String body, String quotedText, String subject, final ContentValues extraValues) { Intent intent = new Intent(ACTION_LAUNCH_COMPOSE); intent.setPackage(context.getPackageName()); intent.putExtra(EXTRA_FROM_EMAIL_TASK, true); intent.putExtra(EXTRA_ACTION, action); intent.putExtra(Utils.EXTRA_ACCOUNT, account); if (action == EDIT_DRAFT) { intent.putExtra(ORIGINAL_DRAFT_MESSAGE, message); } else {//from w w w .j ava 2s .c om intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (toAddress != null) { intent.putExtra(EXTRA_TO, toAddress); } if (body != null) { intent.putExtra(EXTRA_BODY, body); } if (quotedText != null) { intent.putExtra(EXTRA_QUOTED_TEXT, quotedText); } if (subject != null) { intent.putExtra(EXTRA_SUBJECT, subject); } if (extraValues != null) { LogUtils.d(LOG_TAG, "Launching with extraValues: %s", extraValues.toString()); intent.putExtra(EXTRA_VALUES, extraValues); } if (action == COMPOSE) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else if (message != null) { intent.setData(Utils.normalizeUri(message.uri)); } context.startActivity(intent); }
From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java
/** * ??/* w ww. ja v a 2 s.co m*/ * * @param message ? * @param boxType ?? * tableName ??a * @return ?ID */ public static long insertIMessage(ECMessage message, int boxType) { long ownThreadId = 0; long row = 0L; try { if (!TextUtils.isEmpty(message.getSessionId())) { String contactIds = message.getSessionId(); if (contactIds.toUpperCase().startsWith("G")) { GroupSqlManager.checkGroup(contactIds); } checkContact(message.getForm(), message.getNickName()); ownThreadId = ConversationSqlManager.querySessionIdForBySessionId(contactIds); if (ownThreadId == 0) { try { ownThreadId = ConversationSqlManager.insertSessionRecord(message); } catch (Exception e) { LogUtil.e(TAG + " " + e.toString()); } } if (ownThreadId > 0) { int isread = IMESSENGER_TYPE_UNREAD; if (boxType == IMESSENGER_BOX_TYPE_OUTBOX || boxType == IMESSENGER_BOX_TYPE_DRAFT) { isread = IMESSENGER_TYPE_READ; } ContentValues values = new ContentValues(); if (boxType == IMESSENGER_BOX_TYPE_DRAFT) { try { // ??? values.put(IMessageColumn.OWN_THREAD_ID, ownThreadId); values.put(IMessageColumn.sender, message.getForm()); values.put(IMessageColumn.MESSAGE_ID, message.getMsgId()); values.put(IMessageColumn.MESSAGE_TYPE, message.getType().ordinal()); values.put(IMessageColumn.SEND_STATUS, message.getMsgStatus().ordinal()); values.put(IMessageColumn.READ_STATUS, isread); values.put(IMessageColumn.BOX_TYPE, boxType); values.put(IMessageColumn.BODY, ((ECTextMessageBody) message.getBody()).getMessage()); values.put(IMessageColumn.USER_DATA, message.getUserData()); values.put(IMessageColumn.RECEIVE_DATE, System.currentTimeMillis()); values.put(IMessageColumn.CREATE_DATE, message.getMsgTime()); row = getInstance().sqliteDB().insertOrThrow(DatabaseHelper.TABLES_NAME_IM_MESSAGE, null, values); } catch (SQLException e) { LogUtil.e(TAG + " " + e.toString()); } finally { ChattingFragment.isFireMsg = false; values.clear(); } } else { try { values.put(IMessageColumn.OWN_THREAD_ID, ownThreadId); values.put(IMessageColumn.MESSAGE_ID, message.getMsgId()); values.put(IMessageColumn.SEND_STATUS, message.getMsgStatus().ordinal()); values.put(IMessageColumn.READ_STATUS, isread); values.put(IMessageColumn.BOX_TYPE, boxType); // values.put(IMessageColumn.VERSION, // message.getVersion()); values.put(IMessageColumn.USER_DATA, message.getUserData()); values.put(IMessageColumn.RECEIVE_DATE, System.currentTimeMillis()); values.put(IMessageColumn.CREATE_DATE, message.getMsgTime()); values.put(IMessageColumn.sender, message.getForm()); values.put(IMessageColumn.MESSAGE_TYPE, message.getType().ordinal()); if (message.getType() == Type.VIDEO && message.getDirection() == Direction.RECEIVE) { ECVideoMessageBody videoBody = (ECVideoMessageBody) message.getBody(); values.put(IMessageColumn.BODY, videoBody.getLength() + ""); } if (message.getType() == Type.RICH_TEXT) { ECPreviewMessageBody body = (ECPreviewMessageBody) message.getBody(); values.put(IMessageColumn.FILE_URL, body.getUrl()); values.put(IMessageColumn.BODY, body.getTitle()); values.put(IMessageColumn.FILE_PATH, body.getLocalUrl()); } if (message.getType() == Type.IMAGE && message.getDirection() == Direction.RECEIVE) { values.put(IMessageColumn.BODY, message.getUserData()); } if (message.getType() == Type.IMAGE && message.getDirection() == Direction.SEND && ChattingFragment.isFireMsg) { values.put(IMessageColumn.BODY, "fireMessage"); } // ? putValues(message, values); LogUtil.d(TAG, "[insertIMessage] " + values.toString()); row = getInstance().sqliteDB().insertOrThrow(DatabaseHelper.TABLES_NAME_IM_MESSAGE, null, values); } catch (SQLException e) { e.printStackTrace(); LogUtil.e(TAG + " " + e.toString()); } finally { ChattingFragment.isFireMsg = false; values.clear(); } } getInstance().notifyChanged(contactIds); } } } catch (Exception e) { LogUtil.e(e.getMessage()); } return row; }
From source file:com.tct.mail.compose.ComposeActivity.java
private static void launch(Context context, Account account, Message message, int action, String toAddress, String body, String quotedText, String subject, final ContentValues extraValues) { //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S if (message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024 * 5) { message.bodyHtml = ""; LogUtils.d("Email", "test---launch---bodyHtml set to empty"); }/*w w w . j a v a 2 s. c o m*/ if (message != null && message.bodyText != null && message.bodyText.length() > 1024 * 5) { message.bodyText = ""; LogUtils.d("Email", "test---launch---bodyText set to empty"); } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_E //Note: intent can not take too much extra data, so not take these two string in extra data. if (message != null) { message.bodyHtmlLinkify = ""; message.bodyTextLinkify = ""; } Intent intent = new Intent(ACTION_LAUNCH_COMPOSE); intent.setPackage(context.getPackageName()); intent.putExtra(EXTRA_FROM_EMAIL_TASK, true); intent.putExtra(EXTRA_ACTION, action); intent.putExtra(Utils.EXTRA_ACCOUNT, account); if (action == EDIT_DRAFT) { intent.putExtra(ORIGINAL_DRAFT_MESSAGE, message); } else { intent.putExtra(EXTRA_IN_REFERENCE_TO_MESSAGE, message); } if (message != null) { LogUtils.d("Email", String.format("test---launch---action=%d messageId=%d conversationUri=%s uri=%s subject=%s", action, message.id, message.conversationUri, message.uri, message.subject)); } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S // if(message != null && message.bodyHtml != null && message.bodyHtml.length() > 1024*10){ // message.bodyHtml = ""; // Log.d("Email","test---launch---bodyHtml set to empty"); // } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E if (toAddress != null) { intent.putExtra(EXTRA_TO, toAddress); } if (body != null) { intent.putExtra(EXTRA_BODY, body); } if (quotedText != null) { intent.putExtra(EXTRA_QUOTED_TEXT, quotedText); } if (subject != null) { intent.putExtra(EXTRA_SUBJECT, subject); } if (extraValues != null) { LogUtils.d(LOG_TAG, "Launching with extraValues: %s", extraValues.toString()); intent.putExtra(EXTRA_VALUES, extraValues); } if (action == COMPOSE) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else if (message != null) { //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_S if (message.uri == null) { LogUtils.e(LOG_TAG, "what ? message's uri is null? want launch ComposeActivity ? do nothing is the right thing!!!"); return; } //TS: jin.dong 2015-10-19 EMAIL BUGFIX_1100033 ADD_E //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_S intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //TS: yanhua.chen 2016-03-31 EMAIL BUGFIX_1877378 ADD_E intent.setData(Utils.normalizeUri(message.uri)); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_S //context.startActivity(intent); try { context.startActivity(intent); } catch (Exception e) { LogUtils.e(LOG_TAG, "Launch compose activity err."); } // TS: xiaolin.li 2015-01-29 EMAIL BUGFIX-917401 ADD_E }