Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of sending short message in Android

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to send SMS in Android", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to achieve SMS sending function in Android" article.

1: Android SMS transmission can be simulated in the simulator.

For example, start a simulator id 5554 now and run cmd

Telnet localhost 5554

Enter help to see many functional commands for use in the simulator

Gsm call 134343434 / / is to call the current simulator command sms send 15555218135 Hello,this is a Message / / is to send a short message to the current simulator

2: related classes:

Android.telephony.gsm.SmsManager Android.telephony.gsm.SmsMessage Android.app.PendingIntent Android.widget.Toast

3:Android SMS sending implementation code (excerpt)

String msg = "hello"

String number = "1234565678"

SmsManager sms = SmsManager.getDefault ()

PendingIntent pi = PendingIntent.

GetBroadcast (Sms.this,0,new Intent (), 0)

Sms.sendTextMessage (number,null,msg,pi,null)

Toast.makeText (Sms.this, "send success"

Toast.LENGHT_LONG) .show ()

Explanation of 4:Android SMS sending code

The above code for sending SMS messages is simple, but some of the class functions are not easy to understand:

A brief introduction to the realization of gravity induction in Android

Overview of Android Theme details

Summary of Android Application skills

A brief discussion on the realization method of displaying Network Pictures on Android

A brief introduction to the specific Operation method of Android Boot self-start

Toast.makeText is to display a prompt message, which is easier to understand.

PendingIntent is an Intent description, and we can give this description to other programs, other programs.

According to this description, do what you arrange to do at some other time later, By giving a PendingIntent to another application you are granting it the right to perform the operation you have specified as if the other

Application was yourself is equivalent to your representative. The other program in this example is the program that sends SMS messages. After the SMS messages are sent successfully, the intent will be broadcast.

Function sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

The first three parameters are easy to understand according to the document. PendingIntent sentIntent when a text message is sent, sendIntent will broadcast its internal description of intent if it is successful, otherwise an error code will be generated and callback will be made through Android.app.PendingIntent.OnFinished. This parameter * is not empty, otherwise there will be potential problems of wasting resources.

A deliveryIntent is an PendingIntent broadcast when a message has been delivered to the recipient.

Looking at the PendingIntent class, you can see that there are many Send functions, that is, PendingIntent is doing the relevant operations that are assigned to it.

The above is about the content of this article on "how to send SMS in Android". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report