当发送大于12片长短信,使其不能发送,且给客户提示

本文介绍如何通过修改MmsConfigImpl.java文件中的sSmsToMmsTextThreshold值来防止长短信自动转换为彩信,并展示了如何在composemessageactivity.java中限制短信长度超过12页的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.使长短信不能自动转彩信。
2.当短信页数超过12条,使该短信不能发送,并提示客户删除字符。
 
[SOLUTION]
1.MmsConfigImpl.java中
   private static int sSmsToMmsTextThreshold = 4;
  把这个值改为999。
 
2.在composemessageactivity.java中
a.在updateCounter函数中,对msgCount做判断,若当前大于12页则提醒客户已超过12页,并要求删除字符。
    private void updateCounter(CharSequence text, int start, int before, int count) {
 ......
        params = SmsMessage.calculateLength(text, false, encodingType);
            /* SmsMessage.calculateLength returns an int[4] with:
             *   int[0] being the number of SMS's required,
             *   int[1] the number of code units used,
             *   int[2] is the number of code units remaining until the next message.
             *   int[3] is the encoding type that should be used for the message.
             */
        final int msgCount = params[0];

 
在这里添加toast提醒客户,并使用全局变量保存msgCount 。
 
b.在SendButton的onClick函数:
大概6096行:当v == mSendButtonSms的时候,对全局变量做判断,大于12则直接退出函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值