Joke Collection Website - Public benefit messages - How to judge the status of Android after sending multiple short messages?

How to judge the status of Android after sending multiple short messages?

SMS manager SMS manager = SMS manager . get default(); //Get the SMS manager, which is the default SMS manager of Android system, and you can send SMS through it.

List & lt string & gt contents = SMS manager. Divide message (content); //multiple text messages. Here, the short message with long content is divided into multiple short messages to send.

For (string text: content) (

SMS manager . sendtextmessage(destination address,scAddress,text,sentIntent,delivery intent); //Send SMS

}

When you send a text message, there are two results. One is whether the message was sent successfully, and the other is whether the other party received it successfully. Whether the SMS is sent successfully is not determined by the Android program. Short messages are sent by short message base stations, such as mobile. We only need to send short messages to the mobile wireless communication network. If the network sends SMS successfully, the mobile phone will return a signal, which will be captured by the program.

The program captures the signal asynchronously, because it is impossible to keep the thread open and wait for the returned signal, so the last two parameters of sendTextMessage (), sentIntent and deliveryIntent, are used to accept the sending and receiving status signals.

SentIntent is the intention of whether the short message is sent successfully or not; DeliveryIntent is the intention of the receiver to receive the short message. If you don't want to receive the returned signal, you can set it to null.

After sending the intention, if the mobile network returns the signal of success or failure in sending the short message, the operating system will broadcast the intention asynchronously, and you will know the status of the short message.