I used a simple Phone Dialer before, so it was easy to get started when I was sending text messages. In fact, their principle is basically the same. I only implement one-to-one SMS sending. Of course, if you want to send a group message, you can also store all the phone numbers in an array, then you can traverse them one by one. One-to-one messages will be sent and sent in a group. Through this smallProgramI will make the following summary:
(1)
Like the Phone Dialer program, Android actually provides us with a manager internally, as long as we use some of its methods.
(2)
It also involves a permission issue. Unlike the phone dial, it uses a permission to send text messages,CodeAs follows:
<Uses-Permission Android: Name = "android. Permission. send_sms"> </uses-Permission>
You only need to add it to the manifest file. In fact, what I want to say here is that, in fact, there are many things, many knowledge points, many methods, and the meaning of each parameter, which have been defined and written in the SDK documentation, we only need to read it. Now, I feel that the document is really a good thing. We can never understand every method, nor do we need to understand it. To be precise, we simply cannot understand it. When we use it and do not know what it means, we can query its documents, which is also good for improving our English.
(3)
In the text message sender, if you want to send a short message after sending it, and then it disappears naturally, you can try to write the following code:
Toast. maketext (smsactivity. This, "sent successfully", Toast. length_short). Show ();
Of course, the above is just an example. You can change the parameter content as needed. There are two methods for this toast (toast) class. I just used one of them, and the other method is similar, but there is a different parameter. To put it bluntly, the next method is to better support internationalization. As for what specific parameters mean, we can refer to its documentation to see what they mean, which is easy to understand. Remember to write. Show (), or it will not be displayed.
The above is my summary after writing this small program. I hope to share with you!