MMS发送流程代码版androidWord格式文档下载.docx
《MMS发送流程代码版androidWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《MMS发送流程代码版androidWord格式文档下载.docx(27页珍藏版)》请在冰豆网上搜索。
![MMS发送流程代码版androidWord格式文档下载.docx](https://file1.bdocx.com/fileroot1/2022-11/27/ecd8148a-dc66-489c-b87c-106c55728f9f/ecd8148a-dc66-489c-b87c-106c55728f9f1.gif)
return;
booleanisMms=mWorkingMessage.requiresMms();
//是否需要以彩信形式发送
if(mRecipientsEditor.hasInvalidRecipient(isMms)){//是否含有不合法的收件人
if(mRecipientsEditor.hasValidRecipient(isMms)){//有合法的和不合法的,弹出尝试发送对话框
Stringtitle=getResourcesString(R.string.has_invalid_recipient,
mRecipientsEditor.formatInvalidNumbers(isMms));
newAlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(title)
.setMessage(R.string.invalid_recipient_message)
.setPositiveButton(R.string.try_to_send,
newSendIgnoreInvalidRecipientListener())
.setNegativeButton(R.string.no,newCancelSendingListener())
.show();
}else{//如果全是不合法的联系人,提示不能发送信息
.setTitle(R.string.cannot_send_message)
.setMessage(R.string.cannot_send_message_reason)
.setPositiveButton(R.string.yes,newCancelSendingListener())
}else{//判断收件人没有问题,接着发送信息--》
3.src//android/mms/ui/poseMessageActivity.java
privatevoidsendMessage(booleanbCheckEcmMode){
Log.v(TAG,"
sendMessage"
);
if(bCheckEcmMode){
//TODO:
exposethisintelephonylayerforSDKbuild
StringinEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE);
//判断是否处于紧急拨号模式,得到的inEcm一般为空
inEcm="
+inEcm);
if(Boolean.parseBoolean(inEcm)){
try{
startActivityForResult(
newIntent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS,null),
REQUEST_CODE_ECM_EXIT_DIALOG);
}catch(ActivityNotFoundExceptione){
//continuetosendmessage
Log.e(TAG,"
CannotfindEmergencyCallbackModeExitDialog"
e);
mSendingMessage){
//sendcanchangetherecipients.Makesureweremovethelistenersfirstandthenadd
//thembackoncetherecipientlisthassettled.
removeRecipientsListeners();
//取消对收件人的监听
mWorkingMessage.send();
//发送信息—-》
mSentMessage=true;
mSendingMessage=true;
addRecipientsListeners();
//重新添加收件人监听
//Butbailoutifwearesupposedtoexitafterthemessageissent.
if(mExitOnSent){//如果mExitOnSent为true,信息发送完成后退出Activity
finish();
4.src//android/mms/data/WorkingMessage.java
/**
*Sendthismessageoverthenetwork.
WillcallbackwithonMessageSent()once
*ithasbeendispatchedtothetelephonystack.
ThisWorkingMessageobjectis
*nolongerusefulafterthismethodhasbeencalled.
*/
publicvoidsend(){
if(Log.isLoggable(LogTag.TRANSACTION,Log.VERBOSE)){
LogTag.debug("
send"
//Getreadytowritetodisk.
prepareForSave(true/*notify*/);
//主要做一下同步收件人和WorkingMessage,彩信时在准备其他一些东西
//WeneedtherecipientlistforbothSMSandMMS.
finalConversationconv=mConversation;
StringmsgTxt=mText.toString();
msgText="
+msgTxt);
if(requiresMms()||addressContainsEmailToMms(conv,msgTxt)){
//Makelocalcopiesofthebitsweneedforsendingamessage,
//becausewewillbedoingitoffofthemainthread,whichwill
//immediatelycontinueontoresettingsomeofthisstate.
finalUrimmsUri=mMessageUri;
//如果第一次发送,此时mmsUri为null,如果是重发,则是草稿箱的地址mMessageUri=content:
//mms/drafts/1
finalPduPersisterpersister=PduPersister.getPduPersister(mContext);
finalSlideshowModelslideshow=mSlideshow;
finalSendReqsendReq=makeSendReq(conv,mSubject);
//DothedirtyworkofsendingthemessageoffofthemainUIthread.
newThread(newRunnable(){
publicvoidrun(){
//Makesurethetextinslide0isnolongerholdingontoareferenceto
//thetextinthemessagetextbox.
slideshow.prepareForSend();
sendMmsWorker(conv,mmsUri,persister,slideshow,sendReq);
}).start();
}else{
//Samerulesapplyasabove.
finalStringmsgText=mText.toString();
//取出短消息
+msgText);
preSendSmsWorker(conv,msgText);
//发送信息--》
//updatetheRecipientcachewiththenewtoaddress,ifit'
sdifferent
RecipientIdCache.updateNumbers(conv.getThreadId(),conv.getRecipients());
//Markthemessageasdiscardedbecauseitis"
offthemarket"
afterbeingsent.
mDiscarded=true;
5.src//android/mms/data/WorkingMessage.java
privatevoidsendMmsWorker(Conversationconv,UrimmsUri,PduPersisterpersister,SlideshowModelslideshow,SendReqsendReq){
sendMmsWorker"
//Ifusertriestosendthemessage,it'
sasignaltheinputtedtextiswhattheywanted.
UserHappinessSignals.userAcceptedImeText(mContext);
//Firstmakesurewedon'
thavetoomanyoutstandingunsentmessage.
Cursorcursor=null;
cursor=SqliteWrapper.query(mContext,mContentResolver,
Mms.Outbox.CONTENT_URI,MMS_OUTBOX_PROJECTION,null,null,null);
if(cursor!
=null){//如果MMS_OUTBOX里有未发送的彩信,并且总的大小已经超过了彩信的最大限制,则取消此次发送,并存入草稿箱
queryMms.Outbox.CONTENT_URIisnotempty"
longmaxMessageSize=MmsConfig.getMaxSizeScaleForPendingMmsAllowed()*
MmsConfig.getMaxMessageSize();
MmsConfig.getMaxSizeScaleForPendingMmsAllowed()="
+MmsConfig.getMaxSizeScaleForPendingMmsAllowed());
MmsConfig.getMaxMessageSize()()="
+MmsConfig.getMaxMessageSize());
longtotalPendingSize=0;
while(cursor.moveToNext()){
totalPendingSize+=cursor.getLong(MMS_MESSAGE_SIZE_INDEX);
totalPendingSize="
+totalPendingSize);
if(totalPendingSize>
=maxMessageSize){
unDiscard();
//itwasn'
tsuccessfullysent.Allowittobesavedasadraft.
mStatusListener.onMaxPendingMessagesReached();
}else{
queryMms.Outbox.CONTENT_URIisempty"
}finally{
=null){
cursor.close();
mStatusListener.onPreMessageSent();
//MakesurewearestillusingthecorrectthreadIDforour
//recipientset.
longthreadId=conv.ensureThreadId();
if(Log.isLoggable(LogTag.APP,Log.VERBOSE)){
sendMmsWorker:
updatedraftMMSmessage"
+mmsUri);
if(mmsUri==null){//如果是首次发送,先把彩信保存入草稿箱
//CreateanewMMSmessageifonehasn'
tbeenmadeyet.
mmsUri==nullandstartcreateDraftMmsMessage"
mmsUri=createDraftMmsMessage(persister,sendReq,slideshow);
}else{
//Otherwise,synctheMMSmessageinprogresstodisk.
mmsUri="
updateDraftMmsMessage"
updateDraftMmsMessage(mmsUri,persister,slideshow,sendReq);
//BeparanoidandcleananydraftSMSup.
deleteDraftSmsMessage(threadId);
//Resizealltheresizeableattachments(e.g.pictures)tofit
//intheremainingspaceintheslideshow.
interror=0;
slideshow.finalResize(mmsUri);
}catch(ExceedMessageSizeExceptione1){
error=MESSAGE_SIZE_EXCEEDED;
}catch(MmsExceptione1){
error=UNKNOWN_ERROR;
if(error!
=0){
markMmsMessageWithError(mmsUri);
mStatusListener.onAttachmentError(error);
MessageSendersender=newMmsMessageSender(mContext,mmsUri,
slideshow.getCurrentMessageSize());
sender.sendMessage(threadId)){
//ThemessagewassentthroughSMSprotocol,weshould
//deletethecopywhichwaspreviouslysavedinMMSdrafts.
SqliteWrapper.delete(mContext,mContentResolver,mmsUri,null,null);
//Makesurethisthreadisn'
toverthelimitsinmessagecount