简体   繁体   English

smsManager.sendTextMessage不适用于超过一个sms字符限制的消息

[英]smsManager.sendTextMessage not working for message that exceeds one sms character limit

I am working with a project which sends firebase dynamic link invitation to friends via sms. 我正在使用一个项目,通过短信向朋友发送firebase动态链接邀请。 My code runs perfecly fine and sends sms when I send smaller links as invitation. 当我发送较小的链接作为邀请时,我的代码运行完全正常并发送短信。 like 喜欢

    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();
    }

But it doesn't send sms when I include bigger link which exceeds one sms character limit though it shows the toast notification. 但是当我包含超过一个sms字符限制的更大链接时它不会发送短信,尽管它显示了吐司通知。

    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();
    }

what shall I do to include the whole link which is in myNewLink and make it working. 我该怎么做才能包含myNewLink中的整个链接并使其正常工作。 Thank you. 谢谢。

This code might help you: 此代码可能对您有所帮助:

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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM