コード例 #1
0
  private void sendMessage(boolean forcePlaintext, boolean forceSms) {
    try {
      Recipients recipients = getRecipients();

      if (recipients == null) throw new RecipientFormattingException("Badly formatted");

      long allocatedThreadId;

      if ((!recipients.isSingleRecipient() || recipients.isEmailRecipient()) && !isMmsEnabled) {
        handleManualMmsRequired();
        return;
      } else if (attachmentManager.isAttachmentPresent()
          || !recipients.isSingleRecipient()
          || recipients.isGroupRecipient()
          || recipients.isEmailRecipient()) {
        allocatedThreadId = sendMediaMessage(forcePlaintext, forceSms);
      } else {
        allocatedThreadId = sendTextMessage(forcePlaintext, forceSms);
      }

      sendComplete(recipients, allocatedThreadId, allocatedThreadId != this.threadId);
    } catch (RecipientFormattingException ex) {
      Toast.makeText(
              ConversationActivity.this,
              R.string
                  .ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation,
              Toast.LENGTH_LONG)
          .show();
      Log.w(TAG, ex);
    } catch (InvalidMessageException ex) {
      Toast.makeText(
              ConversationActivity.this,
              R.string.ConversationActivity_message_is_empty_exclamation,
              Toast.LENGTH_SHORT)
          .show();
      Log.w(TAG, ex);
    } catch (MmsException e) {
      Log.w(TAG, e);
    }
  }
コード例 #2
0
 public void display() {
   if (recipients.isGroupRecipient()) execute();
   else onPostExecute(recipients);
 }