Lec 15 MAD
Lec 15 MAD
15 07-01-2025
Instructor:
Ms. Atika Tanveer
1/13/2025 1
Using Built-in Intent to send SMS
You can use Android Intent to send SMS by calling built-in SMS
functionality of the Android.
Following section explains different parts of our Intent object
required to send an SMS.
1/13/2025 2
Intent Object - Action to send SMS
You will use ACTION_VIEW action to launch an SMS client installed
on your Android device. Following is simple syntax to create an intent
with ACTION_VIEW action.
1/13/2025 3
Intent Object - Data/Type to send SMS
To send an SMS you need to specify smsto: as URI using setData()
method and data type will be to vnd.android-dir/mms-sms using
setType() method as follows −
1/13/2025 4
Intent Object - Extra to send SMS
Android has built-in support to add phone number and text message
to send an SMS as follows −
1/13/2025 5
Example
Following example shows you in practical how to use Intent object to
launch SMS client to send an SMS to the given recipients.
Step Description
You will use Android studio IDE to create an Android application and name it
1
as tutorialspoint under a package com.example.tutorialspoint.
Modify src/MainActivity.java file and add required code to take care of sending
2
SMS.
Modify layout XML file res/layout/activity_main.xml add any GUI component if
3
required. I'm adding a simple button to launch SMS Client.
4 No need to define default constants.Android studio takes care of default constants.
5 Modify AndroidManifest.xml as shown below
Run the application to launch Android emulator and verify the result of the changes
6
done in the application.
1/13/2025 6
activity_main.xml
1/13/2025 7
MainActivity.java
1/13/2025 8
Output
1/13/2025 9
1/13/2025 10
Send an Email From an Android Application
Working with the XML Files
go to the activity_main.xml file, which represents the UI of the project.
Below is the code for the activity_main.xml file. Comments are added inside
the code to understand the code in more detail. This file contains a Relative
Layout which contains three Edit texts for receiver mail id, another for the
subject of the mail, and last one for the body of the email, and three
TextViews for the label and a button for starting intent or sending mail:
1/13/2025 11
activity_main.xml
1/13/2025 12
1/13/2025 13
MainActivity.js
1/13/2025 14
MainActivity.js
1/13/2025 15
Output
1/13/2025 16
Thank You
1/13/2025 17