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

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

我正在处理一个通过短信向朋友发送 firebase 动态 link 邀请的项目。当我发送较小的 link 作为邀请时,我的代码运行得非常好并发送短信。喜欢

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

但是当我包含更大的 link 时它不发送短信,尽管它显示了 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();
    }

我该怎么做才能将整个 link 包含在 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();
}