You are on page 1of 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment – 2.3

Student Name: Garima Jain UID: 21BCS2064


Branch: BE-CSE Section: 21BCS_608 - A
Semester: 06 Date of Performance: 05-03-2024
Subject Name: MAD Lab Subject Code: 21CSH-355

1. Aim: To design an Android application to Send SMS using Intent.

2. Objective: The objective of an Android-based application that uses Intent to send


SMS can be to create a convenient and user-friendly tool for sending text messages.
This type of app aims to leverage the Android platform's capabilities to provide a
seamless and efficient way for users to compose and send SMS messages.

3. Input/Apparatus Used:

To create an Android app that uses Intent with a button to create a page and
passes values from one activity to another, you will need the following tools and
resources:
1. Integrated Development Environment (IDE): Android Studio: The official
IDE for Android development. Download and install Android Studio from the
official website: Android Studio.
2. Android SDK: The Android Software Development Kit (SDK) is essential for
developing Android applications. Android Studio usually comes bundled with
the SDK, but you may need to update it through the SDK Manager within
Android Studio.
3. Java Development Kit (JDK): Android apps are primarily written in Java or
Kotlin. Make sure you have the Java Development Kit installed. Android
Studio supports JDK. You can download it from the Oracle website: Java SE
Downloads.
4. Android Virtual Device (AVD) or Physical Android Device: You need a
device to test your Android application. You can use an emulator (AVD) that
comes with Android Studio or a physical Android device connected to your
computer.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

SOURCE CODE:
Main Activity Java File
package com.example.sms; import android.os.Bundle; import android.app.Activity;
import android.telephony.gsm.SmsManager; import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener; import android.widget.Button;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState
{
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Button bt=(Button)findViewById(R.id.button1); bt.setOnClickListener(new
OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub SmsManager sms=SmsManager.getDefault();
sms.sendTextMessage("5554", null, "hai", null, null);
}
});
}
public boolean onCreateOptionsMenu(Menu menu)
{
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
MainActivity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
android:layout_marginLeft="54dp" android:layout_marginTop="166dp"
android:text="send" />
</RelativeLayout>

Output:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

4. Learning Outcome: In this experiment, we learnt about


a. Developing an Android-based application that uses Intent to send SMS can be
to create a convenient and user-friendly tool for sending text messages.
b. Android platform's capabilities to provide a seamless and efficient way for
users to compose and send SMS messages.

You might also like