The example of this article describes the Android SMS function code, which is a very common important function in the development of Android programs. Share for everyone to use for reference. The specific methods are as follows:
Send SMS public
void Sendmsg () {
String content = Edtsend.gettext (). toString ();
Smsmanager Smsmanager = Smsmanager.getdefault ();
list<string> dividecontents = smsmanager.dividemessage (content);
for (String text:dividecontents) {
smsmanager.sendtextmessage (smswidget.str_number, NULL, text, NULL, NULL);
}
The above code first obtains a Smsmanager instance, and then uses the Dividemessage () method to divide the text content into several parts, because if the text message content is too long, may exceed the maximum length which allows to send, then needs to divide the text content into several strings , in general, the content will not exceed the maximum length, so it is a string; Finally, for all strings, use the Sendtextmessage () method to send, where smswidget.str_number is the offset number and text is each string.
I hope this article will help you with your Android program.