List of usage examples for android.telephony TelephonyManager ACTION_RESPOND_VIA_MESSAGE
String ACTION_RESPOND_VIA_MESSAGE
To view the source code for android.telephony TelephonyManager ACTION_RESPOND_VIA_MESSAGE.
Click Source Link
From source file:com.android.messaging.datamodel.NoConfirmationSmsSendService.java
@Override protected void onHandleIntent(final Intent intent) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent"); }// ww w .ja v a 2s. c om final String action = intent.getAction(); if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent wrong action: " + action); } return; } final Bundle extras = intent.getExtras(); if (extras == null) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Called to send SMS but no extras"); } return; } // Get all possible extras from intent final String conversationId = intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID); final String selfId = intent.getStringExtra(EXTRA_SELF_ID); final boolean requiresMms = intent.getBooleanExtra(UIIntents.UI_INTENT_EXTRA_REQUIRES_MMS, false); final String message = getText(intent, Intent.EXTRA_TEXT); final String subject = getText(intent, Intent.EXTRA_SUBJECT); final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID); final Uri intentUri = intent.getData(); final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null; if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Both conversationId and recipient(s) cannot be empty"); } return; } if (extras.getBoolean("showUI", false)) { startActivity(new Intent(this, ConversationListActivity.class)); } else { if (TextUtils.isEmpty(message)) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Message cannot be empty"); } return; } // TODO: it's possible that a long message would require sending it via mms, // but we're not testing for that here and we're sending the message as an sms. if (TextUtils.isEmpty(conversationId)) { InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject); } else { MessageData messageData = null; if (requiresMms) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + conversationId); } messageData = MessageData.createDraftMmsMessage(conversationId, selfId, message, subject); } else { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending SMS message in conversation: " + conversationId); } messageData = MessageData.createDraftSmsMessage(conversationId, selfId, message); } InsertNewMessageAction.insertNewMessage(messageData); } UpdateMessageNotificationAction.updateMessageNotification(); } }
From source file:com.cyanogenmod.messaging.quickmessage.QuickMessagePopup.java
/** * Use standard api to send the supplied message * * @param message - message to send//from w w w. j a va2 s . c o m * @param qm - qm to reply to (for sender details) * @param subId - the subscription to use */ private void sendQuickMessage(String message, QuickMessage qm, int subId) { if (message != null && qm != null) { Intent sendIntent = new Intent(this, NoConfirmationSmsSendService.class); sendIntent.setAction(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE); sendIntent.putExtra(NoConfirmationSmsSendService.EXTRA_SUBSCRIPTION, subId); sendIntent.putExtra(Intent.EXTRA_TEXT, stripUnicodeIfRequested(message)); sendIntent.setData(qm.getRecipientsUri()); startService(sendIntent); Toast.makeText(mContext, R.string.toast_sending_message, Toast.LENGTH_SHORT).show(); } }