Detailed explanation of Android SMS sending method example

This article describes the method of sending SMS by Android. Share with you for your reference, as follows:

SMS, like making a phone call, is the basic function of Android mobile phone. The following is an example to illustrate how Android realizes the function of sending SMS.

The procedure is as follows:

Androidmanifest.xml is as follows:

When the pendingintent object is received, the broadcast action will be performed, just like the context. Sendbroadcast() method, which is why pendingintent needs to be passed in the smsmanager. Sendtextmessage() method as one of the service parameters.

When I write this program, I directly enter the test through my android smartphone. If there is no android 2.3.3 smartphone nearby, it doesn't matter. You can open two Android simulators through the following methods, one to send information and the other to receive information:

1、 First compile and run the program with eclipse, and then open the first simulator

2、 Open the DOS window (CMD) and enter the following command:

3、 Enter shell command

After these steps, a second simulator will appear. Use the instanceid (e.g. 5546) in the upper left as the recipient's phone number to test the status of SMS delivery.

Sometimes the content of our SMS is likely to exceed 70 words, and we don't want to input paragraph by paragraph. We want to input it directly, and then let the mobile phone automatically help us split it into 70 word SMS. What should we do?

At this time, a method of smsmanager will be used:

Finally, you should pay attention to adding the permission to send SMS in androidmanifest, as shown below:

More readers interested in Android related content can view the special topics of this site: Android control usage summary and Android development introduction and advanced tutorial

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>