Professional Documents
Culture Documents
Mad Ex-2.3
Mad Ex-2.3
Experiment – 2.3
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