我正在尝试从我的Android
应用程序发送短信。一切正常,但缺少一些文本。这是我的代码:
String phoneNumber = "99********"; //Masked the number intentionally.
String message = "";
message += "This is Prabha, and thanks for using my application. ";
message += "Hope you enjoy this application. ";
message += "If you face any problem or issue, you can report the issue to our ";
message += "official mail id: [email protected].";
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, message, null, null);
我正在接收该消息,但是它不完整。缺少一些文字。我只得到以下文字:
This is Prabha, and thanks for using my application. Hope you enjoy this application. If you face any problem or issue, you can report the issue to our officia
我在中添加了以下权限AndroidManifest.xml
:
<uses-permission android:name="android.permission.SEND_SMS" />
我找不到为什么其余文本被截断的原因。我是否应该添加任何其他权限或需要进行任何设置更改?任何想法或帮助将不胜感激。
谢谢。
您需要使用课堂上sendMultipartTextMessage()
可用的方法SmsManager
。
sendTextMessage()
SmsManager
类中可用的方法只能发送长度为160个字符的短信。
若要发送多部分SMS,请使用divideMessage()
SmsManager类中可用的方法来划分消息。然后将其parts
作为中的参数发送sendMultipartTextMessage()
,如下所示:
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(message);
smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句