《MMS发送流程(代码版)android》由会员分享,可在线阅读,更多相关《MMS发送流程(代码版)android(30页珍藏版)》请在金锄头文库上搜索。
1、编号:时间:2021年x月x日书山有路勤为径,学海无涯苦作舟页码:第1页 共1页MMS发送流程(代码版)Android2.2packages/apps/Mms1. 点击发送按钮Src/com/android/mms/ui/ComposeMessageActivity.javapublic void onClick(View v) if (v = mSendButton) & isPreparedForSending() confirmSendMessageIfNeeded(); /确认是否需要发送短信- 2.src/com/android/mms/ui/ComposeMessageActivi
2、ty.javaprivate void confirmSendMessageIfNeeded() if (!isRecipientsEditorVisible() /编辑联系人不可见时,也就是给已存在会话的联系人发送短信时 sendMessage(true); return; boolean isMms = mWorkingMessage.requiresMms(); /是否需要以彩信形式发送 if (mRecipientsEditor.hasInvalidRecipient(isMms) /是否含有不合法的收件人 if (mRecipientsEditor.hasValidRecipient
3、(isMms) /有合法的和不合法的,弹出尝试发送对话框 String title = getResourcesString(R.string.has_invalid_recipient, mRecipientsEditor.formatInvalidNumbers(isMms); new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(title) .setMessage(R.string.invalid_recipient_message) .setPositiveButton
4、(R.string.try_to_send, newSendIgnoreInvalidRecipientListener() .setNegativeButton(R.string.no, new CancelSendingListener() .show(); else /如果全是不合法的联系人,提示不能发送信息 new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.cannot_send_message) .setMessage(R.string.canno
5、t_send_message_reason) .setPositiveButton(R.string.yes, new CancelSendingListener() .show(); else /判断收件人没有问题,接着发送信息 - sendMessage(true); 3. src/com/android/mms/ui/ComposeMessageActivity.javaprivate void sendMessage(boolean bCheckEcmMode) Log.v(TAG, sendMessage); if (bCheckEcmMode) / TODO: expose thi
6、s in telephony layer for SDK build String inEcm = SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE); /判断电话是否处于紧急拨号模式,得到的inEcm一般为空 Log.v(TAG, inEcm = + inEcm); if (Boolean.parseBoolean(inEcm) try startActivityForResult( new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS,null)
7、, REQUEST_CODE_ECM_EXIT_DIALOG); return; catch (ActivityNotFoundException e) / continue to send message Log.e(TAG, Cannot find EmergencyCallbackModeExitDialog, e); if (!mSendingMessage) / send can change the recipients. Make sure we remove the listeners firstand then add / them back once the recipie
8、nt list has settled. removeRecipientsListeners(); /取消对收件人的监听 mWorkingMessage.send(); /发送信息- mSentMessage = true; mSendingMessage = true; addRecipientsListeners(); /重新添加收件人监听 / But bail out if we are supposed to exit after the message is sent. if (mExitOnSent) /如果mExitOnSent为true,信息发送完成后退出Activity fi
9、nish(); 4. src/com/android/mms/data/WorkingMessage.java/* * Send this message over the network. Will call back with onMessageSent() once * it has been dispatched to the telephonystack. This WorkingMessage object is * no longer useful after this method hasbeen called. */ public void send() if (Log.is
10、Loggable(LogTag.TRANSACTION, Log.VERBOSE) LogTag.debug(send); / Get ready to write to disk. prepareForSave(true /* notify */);/主要做一下同步收件人和WorkingMessage,彩信时在准备其他一些东西 / We need the recipient list for both SMS and MMS. final Conversation conv = mConversation; String msgTxt = mText.toString(); Log.v(TA
11、G, msgText = + msgTxt); if (requiresMms()| addressContainsEmailToMms(conv, msgTxt) / Make local copies of the bits we need for sending a message, / because we will be doing it off of the main thread, which will / immediately continue on to resetting some of this state. final Uri mmsUri = mMessageUri
12、; /如果第一次发送,此时mmsUri为null,如果是重发,则是草稿箱的地址 mMessageUri =content:/mms/drafts/1 final PduPersister persister = PduPersister.getPduPersister(mContext); final SlideshowModel slideshow = mSlideshow; final SendReq sendReq = makeSendReq(conv,mSubject); / Do the dirty work of sending the message off of the main UI thread. new Thread(n