问题描述:

1.长按一条输入内容为满的彩信,选择转发

2.输入联系人-删除主题FWD-发送

测试结果为:提示正转化为短信(见附件)

预期结果为:不应该有提示,应该还是彩信

测试结果图为:


根据提示的Toast内容“Converting to text message...”进行代码最终进行代码定位到ComposeMessageActivity类的showConvertToSmsToast()方法,并打印堆栈:

private void showConvertToSmsToast() {

        Log.d("bill",Log.getStackTraceString(new Throwable()));

        Toast.makeText(this, R.string.converting_to_text_message, Toast.LENGTH_SHORT).show();

    }

通过打印堆栈我们可以看出方法的调用流程,我们从下往上来分析到底是哪一个环节除了问题,首先分析ComposeMessageActivity类的onProtocolChanged()方法:

@Override

    public void onProtocolChanged(final boolean convertToMms) {<TAG 1-1>

        // Have to make sure we're on the UI thread. This function can be called off of the UI

        // thread when we're adding multi-attachments

        runOnUiThread(new Runnable() {

            @Override

            public void run() {

                if (mShowTwoButtons) {

                    showTwoSmsOrMmsSendButton(convertToMms);

                } else {

                    showSmsOrMmsSendButton(convertToMms);

                }





                if (convertToMms) {

                    // In the case we went from a long sms with a counter to an mms because

                    // the user added an attachment or a subject, hide the counter --

                    // it doesn't apply to mms.

                    mTextCounter.setVisibility(View.GONE);



                    if (mShowTwoButtons) {

                        mTextCounterSec.setVisibility(View.GONE);

                    }

                    showConvertToMmsToast();

                } else {

                    mTextCounter.setVisibility(View.VISIBLE);

                    showConvertToSmsToast();

                }

            }

        });

   

从上面代码我们分析,当彩信已经发送的时候,该方法不应该在调用,而是应该在输入短息内容的时候进行调用。那我们接着分析WorkingMessage类的updateState()方法,setSubject()方法,removeSubjectIfEmpty()方法,send()方法和sendMessage()方法。

   private void updateState(int state, boolean on, boolean notify) {<TAG1-2>

        if (!sMmsEnabled) {

            // If Mms isn't enabled, the rest of the Messaging UI should not be using any

            // feature that would cause us to to turn on any Mms flag and show the

            // "Converting to multimedia..." message.

            return;

        }

        int oldState = mMmsState;

        if (on) {

            mMmsState |= state;

        } else {

            mMmsState &= ~state;

        }



        // If we are clearing the last bit that is not FORCE_MMS,

        // expire the FORCE_MMS bit.

        if (mMmsState == FORCE_MMS && ((oldState & ~FORCE_MMS) > 0)) {

            mMmsState = 0;

        }



        // Notify the listener if we are moving from SMS to MMS

        // or vice versa.

        if (notify) {

            if (oldState == 0 && mMmsState != 0) {

                mStatusListener.onProtocolChanged(true);

            } else if (oldState != 0 && mMmsState == 0) {

                mStatusListener.onProtocolChanged(false);

            }

        }



        if (oldState != mMmsState) {

            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) LogTag.debug("updateState: %s%s = %s",

                    on ? "+" : "-",

                    stateString(state), stateString(mMmsState));

        }

    }

    public void setSubject(CharSequence s, boolean notify) {<TAG 1-3>

        mSubject = s;

        updateState(HAS_SUBJECT, (s != null), notify);

        if (mSlideshow != null) {

            mSlideshow.setSubjectSize((s == null) ? 0 : s.toString().getBytes().length);

        }

    }



    private void removeSubjectIfEmpty(boolean notify) {<TAG1-4>

        if (!hasSubject()) {

            setSubject(null, notify);

        }

    }

    public void send(final String recipientsInUI) {<TAG1-5>

        long origThreadId = mConversation.getThreadId();



        if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {

            LogTag.debug("send origThreadId: " + origThreadId);

        }



        removeSubjectIfEmpty(true /* notify */);



        // Get ready to write to disk.

        prepareForSave(true /* notify */);



        // We need the recipient list for both SMS and MMS.

        final Conversation conv = mConversation;

        String msgTxt = mText.toString();



        if (requiresMms() || addressContainsEmailToMms(conv, msgTxt)) {

            // uaProfUrl setting in mms_config.xml must be present to send an MMS.

            // However, SMS service will still work in the absence of a uaProfUrl address.

            if (MmsConfig.getUaProfUrl() == null) {

                String err = "WorkingMessage.send MMS sending failure. mms_config.xml is " +

                        "missing uaProfUrl setting.  uaProfUrl is required for MMS service, " +

                        "but can be absent for SMS.";

                RuntimeException ex = new NullPointerException(err);

                Log.e(TAG, err, ex);

                // now, let's just crash.

                throw ex;

            }



            // 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;

            final PduPersister persister = PduPersister.getPduPersister(mActivity);



            final SlideshowModel slideshow = mSlideshow;

            final CharSequence subject = mSubject;

            final boolean textOnly = mAttachmentType == TEXT;



            if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {

                LogTag.debug("Send mmsUri: " + mmsUri);

            }



            // Do the dirty work of sending the message off of the main UI thread.

            new Thread(new Runnable() {

                @Override

                public void run() {

                    final SendReq sendReq = makeSendReq(conv, subject);



                    // Make sure the text in slide 0 is no longer holding onto a reference to

                    // the text in the message text box.

                    slideshow.prepareForSend();

                    sendMmsWorker(conv, mmsUri, persister, slideshow, sendReq, textOnly);



                    updateSendStats(conv);

                }

            }, "WorkingMessage.send MMS").start();

        } else {

            // Same rules apply as above.

            // add user's signature first if this feature is enabled.

            String text = mText.toString();

            SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mActivity);

            if (sp.getBoolean("pref_key_enable_signature", false)) {

                String signature = (sp.getString("pref_key_edit_signature", "")).trim();

                if (signature.length() > 0) {

                    String sigBlock = "\n" + signature;

                    if (!text.endsWith(sigBlock)) {

                        // Signature should be written behind the text in a

                        // newline while the signature has changed.

                        text += sigBlock;

                    }

                }

            }

            final String msgText = text;

            new Thread(new Runnable() {

                @Override

                public void run() {

                    preSendSmsWorker(conv, msgText, recipientsInUI);



                    updateSendStats(conv);

                }

            }, "WorkingMessage.send SMS").start();

        }



        // update the Recipient cache with the new to address, if it's different

        RecipientIdCache.updateNumbers(conv.getThreadId(), conv.getRecipients());



        // Mark the message as discarded because it is "off the market" after being sent.

        mDiscarded = true;

    }



通过对上述代码<TAG 1-3>的方法分析发现,将<TAG 1-3>进行如下修改,问题得到解决。

    public void setSubject(CharSequence s, boolean notify) {<TAG 1-3 MOD>

        mSubject = s;

        if (mSlideshow != null) {

  updateState(HAS_SUBJECT, (s != null), false);

            mSlideshow.setSubjectSize((s == null) ? 0 : s.toString().getBytes().length);

        }else

        updateState(HAS_SUBJECT, (s != null), notify);

}

这里的解决思路为:根据当前幻灯片对象是否为空来判断是否有必要更新状态。

解决在转发一条内容为满的彩信,删除主题FWD,发送的时候提示转化为短信。的更多相关文章

  1. Android--获取短信的内容,截取短信

    1.首先我们要写一个广播接收器,当我们的手机收到短信时,系统会自动发送一个广播,我们只需要接收到这条广播就可以了 2.在广播里面,我们重写的onReceive()方法,通过里面的Intent写到的Bu ...

  2. Android 利用内容观察者实现短信窃听

    <Android 内容观察者的原理>中介绍了内容观察者的一些基本原理,并做了简单的实战,本文接着进一步做一个小项目实战 package com.wuyudong.smslistener; ...

  3. PHP自练项目之发送短信内容

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. 无废话Android之listview入门,自定义的数据适配器、采用layoutInflater打气筒创建一个view对象、常用数据适配器ArrayAdapter、SimpleAdapter、使用ContentProvider(内容提供者)共享数据、短信的备份、插入一条记录到系统短信应用(3)

    1.listview入门,自定义的数据适配器 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and ...

  5. 3、IOS开发--iPad之仿制QQ空间 (为HomeViewController添加交互逻辑 并 为导航条内容添加UISegmentedControl)

    1. 为bottomMenu添加点击效果 思路描述:        需求:        点击BottomButton的三个item,然后对应响应的是HomeViewController弹出对应的业务 ...

  6. 利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码

    利用php CI force_download($filename, $data) 下载.csv 文件解决文件名乱码,文件内容乱码 2014-07-31 12:53 1047人阅读 评论(0) 收藏  ...

  7. repeter 控制一行中显示几条内容

    repeter  控制一行中显示几条内容 <asp:Repeater ID="Repeater1" runat="server" DataSourceID ...

  8. 解决nginx转发websocket报400错误

    解决nginx转发websocket报400错误 说明 由于个人服务器上面有多个项目,配置了二级域名,需要对二级域名进行转发,在转发工作这快采取了大名鼎鼎的nginx.在这之前所有的项目运行转发都没问 ...

  9. 解决:编辑一条彩信,附件选择添加音频,返回到编辑界面选择play,不能播放,没有声音

    [操作步骤]:编辑一条彩信,附件选择添加音频(外部音频),返回到编辑界面选择play,菜单键选择view slideshow [测试结果]:不能播放,没有声音 [预期结果]:可以播放 根据以往的经验( ...

随机推荐

  1. HDU 6072 Logical Chain(Kosaraju+bitset)

    http://acm.hdu.edu.cn/showproblem.php?pid=6072 题意: 给你$n*n$的矩阵,每次修改k条边,让你计算其中能相互到达的点对有多少. 思路: 其实就是求强连 ...

  2. WPF基础学习笔记整理 (二) XAML

    基础知识: XAML:Extensible Application Markup Language, zammel: 用于实例化.NET对象的标记语言: XMAL使用树形逻辑结构描述UI: BAML: ...

  3. shell 杀掉指定进程的服务

    check_results=`ps -ef|grep bp_driver.launch|awk '{print $2}'|sed -n 1p` echo `kill - $check_results` ...

  4. kali删除软件

    kali中主要为2种卸载方法:1.apt2.dpkg 使用apt的方式有:apt-get remove [package]apt-get remove --purge # ------(package ...

  5. jq 便捷api jq 常用 api jq 快捷 api

    jq  选择器 1.相对值用法  width("+=250px") $("input").width("+=250px"); 2.使用函数来 ...

  6. Android网络多线程断点续传下载

    本示例介绍在Android平台下通过HTTP协议实现断点续传下载. 我们编写的是Andorid的HTTP协议多线程断点下载应用程序.直接使用单线程下载HTTP文件对我们来说是一件非常简单的事.那么,多 ...

  7. R语言plot函数参数合集

    最近用R语言画图,plot 函数是用的最多的函数,而他的参数非常繁多,由此总结一下,以供后续方便查阅. plot(x, y = NULL, type = "p", xlim = N ...

  8. php 8小时时间差的解决方法小结

    原来从php5.1.0开始,php.ini里加入了date.timezone这个选项,默认情况下是关闭的 也就是显示的时间(无论用什么php命令)都是格林威治标准时间 和我们的时间(北京时间)差了正好 ...

  9. English trip V1 - 8.What's in My Bag? 我的包里面有什么? Teacher:Corrine Key: plular(复数) and singular(单数)

    In this lesson you will learn to talk about the things you have.   您将学习如何谈论您拥有的东西 课上内容(Lesson) What' ...

  10. English trip V1 - 1.How Do You Feel Now? Teacher:Lamb Key:形容词(Adjectives)

    In this lesson you will learn to describe people, things, and feelings.在本课中,您将学习如何描述人,事和感受. STARTER  ...