How to send SMS on Android systems? How are its settings applied?
5 minute(s) read | Published on: Aug 12, 2021 Updated on: Dec 14, 2021 |
In previous articles, we told you about how to send emails or posts using social networks such as Facebook, LinkedIn, and Twitter, and using the codes. We created an Android application that is easy to work with social networks. In this part of the article, we also want to tell you how to make calls and send SMS (SMS). It should be noted that the possibility of sending short text messages and making calls is essential for all mobile phones and operating systems. This feature must be included in the operating systems because the main reason for the existence of phones is to make calls and send messages.
So, if you want to learn how to create a program to make calls and send messages on the Android operating system, follow this tutorial.
Texting on Android systems
It should be noted that there are two ways to do this:
- Using SMS Manager to send SMS on Android systems - Using the internal Intent to send text in Android systems
Using SMS Manager on Android systems
The first method is to be able to send SMS. To use this method, you must call the SmsManager.getDefault () method. Like the following:
The following is a list of essential and influential methods that are involved in sending SMS, and we use them:
- ArrayList divideMessage (String text):
ArrayList divideMessage (String text) method is used to divide the message's text into several sections. None of the text messages can be considered more than the text.
- static SmsManager getDefault ():
This method can be used to get the default SmsManager instance.
- void sendDataMessage (String destinationAddress, String scAddress, short destinationPort, byte [] data, PendingIntent sentIntent, PendingIntent deliveryIntent): We use this method to be able to send the SMS database to the port of an application.
- void sendMultipartTextMessage (String destinationAddress, String scAddress, ArrayList parts, ArrayList sentIntents, ArrayList deliveryIntents): This method can send a text message that contains several sections.
- void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent): This method can also send a text in SMS format.
In this part of the tutorial, we want to create an application to send SMS in Android systems. In this case, you can easily understand how it works and the process of sending SMS in Android systems.
1- I use Eclipse IDE to create an Android application. 2- Name it SendSMSDemo in the package com.example.sendsmsdemo. 3- Modify the src / MainActivity.java file to add a different code.
4- The res/layout / activity_main file must be modified to add the XML component.
5- Change AndroidManifest.xml to get permissions.
6- All contents and codes that are entirely included in the file and program are as follows:
7- The contents of the res/layout / activity_main.xml file are as follows:
8- The contents of the res/values / strings.xml file are as follows:
9- The contents of the AndroidManifest.xml file are as follows:
10- Run the SendSMSDemo program.
11- You must connect your mobile device to the computer beforehand.
12- To run the program from Eclipse, we must open one of the program activity files and click Run on it.
13- Then, we are faced with a window that it is better to choose our mobile device.
14- Then, we must enter the desired mobile number to finally write a text and send an SMS to that mobile number.
15- After entering the mobile number and the desired text, you can select the Send SMS button to send the SMS to the inserted number.
Using internal Intent to send text
In this method of sending SMS, we must also specify smsto. Note that the URI uses the setData () method in this method.
It should be noted that the Android system has internal support that can be used to enter a mobile number and then send a text message. Like the following:
In the codes above, the address is listed accurately. The only problem is that we must write the characters in lower case.
If you want to send a text message to several numbers simultaneously, you can enter several numbers in the number field and then use the; Separate from each other.
In this part of the tutorial, we want to create an application to send SMS in Android systems. In this case, you can easily understand how it works and the process of sending SMS in Android systems.
1- I use Eclipse IDE to create an Android application.
2- Name it SendSMSDemo in the package com.example.sendsmsdemo.
3- Modify the src / MainActivity.java file to add a different code.
4- The res/layout / activity_main file must be modified to add the XML component.
5- Change AndroidManifest.xml to get permissions.
6- All contents and codes that are entirely included in the file and program are as follows:
7- Content of res / values / strings.xml file:
8- Content of AndroidManifest.xml file:
9- Run the SendSMSDemo program.
10- You must connect your mobile device to the computer beforehand.
11- To run the program from Eclipse, we must open one of the program activity files and click Run on it.
12-Then we are faced with a window, it is better to choose our mobile device.
13- to start internal SMS users, we must select the Compose SMS button.
14- After entering the mobile number and the desired text, you can select the Send text button to send the SMS to the inserted number.
About our Android and iOS app development services