This article describes the Android SMS function code, which is a very common and important function in Android program development. Share it for your reference. The specific methods are as follows:
// sending a text messagepublic void sendMsg(){ String content = ().toString(); SmsManager smsManager = (); List<String> divideContents = (content); for (String text : divideContents) { (smsWidget.str_number, null, text, null, null); } }
The above code first obtains a SmsManager instance; then use the divideMessage() method to divide the content of the SMS into several parts. This is because if the content of the SMS is too long, it may exceed the maximum length allowed to be sent. At this time, the content needs to be divided into several strings. Generally, the content will not exceed the maximum length, so it is still a string; finally, for all strings, use the sendTextMessage() method to send, where smsWidget.str_number is the other party's number and text is each string.
I hope this article will be helpful to everyone's Android programming design.