gpt4 book ai didi

android - smsManager.sendTextMessage 不适用于超过一个短信字符限制的消息

转载 作者:太空狗 更新时间:2023-10-29 15:44:56 30 4
gpt4 key购买 nike

我正在处理一个通过短信向 friend 发送 firebase 动态链接邀请的项目。当我发送较小的链接作为邀请时,我的代码运行良好并发送短信。喜欢

    try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, "Check It Out. This one is very nice and useful https://v5uht.app.goo.gl/Zi7X", null, null);
Toast.makeText(getApplicationContext(), "Cheers :D :D", Toast.LENGTH_LONG).show();
}

catch (Exception e) {
Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}

但是当我包含超过一个短信字符限制的更大链接时,它不会发送短信,尽管它会显示 toast 通知。

    String myNewLink = "https://v5uht.app.goo.gl/?link=http://expensecount.com/&apn=com.chtl.ribath.fdynamic1&amv=1&afl=https://play.google.com/store/apps/details?id%3Dcom.belief.colorgalaxy&myPage=2";
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, myNewLink, null, null);
Toast.makeText(getApplicationContext(), "Cheers :D :D", Toast.LENGTH_LONG).show();
}

catch (Exception e) {
Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}

我应该怎么做才能包含 myNewLink 中的整个链接并使其正常工作。谢谢。

最佳答案

此代码可能对您有帮助:

try {

SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> msgArray = smsManager.divideMessage(msg);

smsManager.sendMultipartTextMessage(phoneNo, null,msgArray, null, null);
Toast.makeText(getApplicationContext(), "Message Sent",Toast.LENGTH_LONG).show();
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), ex.getMessage().toString(), Toast.LENGTH_LONG).show();
ex.printStackTrace();
}

关于android - smsManager.sendTextMessage 不适用于超过一个短信字符限制的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40190081/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com