Mad Exp1
Mad Exp1
M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/loginText"
android:textSize="36dp"
android:textAlignment="center"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/Username"
android:drawablePadding="8dp"
android:hint="Username"
android:padding="8dp"
android:textColor="@color/black"
android:layout_marginTop="40dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/Password1"
android:drawablePadding="8dp"
android:hint="Password"
android:padding="8dp"
android:textColor="@color/black"
android:layout_marginTop="40dp"
android:inputType="textPassword" /> <Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
Name: Chaitra.M
Reg No: 9824037018
android:layout_height="50dp"
android:text="Login" android:textSize="18sp"
android:layout_marginTop="30dp" />
</LinearLayout>
com.example.login;
EditText username;
EditText password;
Button loginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main); username
= findViewById(R.id.Username); password =
findViewById(R.id.Password1);
loginButton = findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(username.getText().toString().equals("user")&&
password.getText().toString().equals("1234")){
Toast.makeText(MainActivity.this, "Login Successful",
Toast.LENGTH_SHORT).show();
Name: Chaitra.M
Reg No: 9824037018
}else{
Toast.makeText(MainActivity.this,"Login
Failed",Toast.LENGTH_SHORT).show();
}
}
});
}}
Output
Result:
Thus to create login page was developed using Android Studio and the output was verified.
Name: Chaitra.M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
<ImageView
android:id="@+id/ImageView"
android:layout_width="350dp"
android:layout_height="350dp"
android:src="@drawable/color3"
/>
<View
android:id="@+id/colorView"
android:layout_width="wrap_content"
android:layout_height="120dp"
/>
<TextView
android:id="@+id/resultTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HEX: \nRGB"
android:textSize="18sp"
android:textColor="#000"
/>
</LinearLayout>
Name: Chaitra.M
Reg No: 9824037018
Colours page activity code: MainActivity.java package
com.example.colors;
import android.graphics.Bitmap;
import android.os.Bundle; import
android.view.MotionEvent; import
android.view.View; import
android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
ImageView mImageView;
TextView mResultTv;
View mColorView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
mImageView.setDrawingCacheEnabled(true);
mImageView.buildDrawingCache(true); mImageView.setOnTouchListener(new
View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() ==
MotionEvent.ACTION_MOVE) {
Bitmap bitmap = mImageView.getDrawingCache();
Output:
Result:
Thus to working with colours and Images was developed using Android Studio and the
output was verified.
Name: Chaitra.M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
<TextView
android:id="@+id/screen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textStyle="bold"
android:textSize="60dp"
android:textColor="#FFFFFF"
android:paddingHorizontal="15dp"
android:paddingVertical="35dp"
android:layout_above="@id/nums"/>
<LinearLayout
android:id="@+id/nums"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingTop="20dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/on"
android:text="ON"
style="@style/Button1"/>
<Button
android:id="@+id/num7"
Name: Chaitra.M
Reg No: 9824037018
android:text="7"
style="@style/Button2"/>
<Button
android:id="@+id/num4"
android:text="4"
style="@style/Button2"/>
<Button
android:id="@+id/num1"
android:text="1"
style="@style/Button2"/>
<Button
android:id="@+id/del"
android:text="DEL"
style="@style/Button1"/>
>
</LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/off"
android:text="off"
style="@style/Button1"/>
<Button
android:id="@+id/num8"
android:text="8"
style="@style/Button2"/>
<Button
android:id="@+id/num5"
android:text="5"
style="@style/Button2"/>
<Button
android:id="@+id/num2"
android:text="2"
style="@style/Button2"/>
<Button
android:id="@+id/num0"
android:text="0"
style="@style/Button2"/>
</LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
Name: Chaitra.M
Reg No: 9824037018
android:orientation="vertical">
<Button
android:id="@+id/ac"
android:text="AC"
style="@style/Button1"/>
<Button
android:id="@+id/num9"
android:text="9"
style="@style/Button2"/>
<Button
android:id="@+id/num6"
android:text="6"
style="@style/Button2"/>
<Button
android:id="@+id/num3"
android:text="3"
style="@style/Button2"/>
<Button
android:id="@+id/point"
android:text="."
style="@style/Button2"/>
</LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/div"
android:text="/"
style="@style/Button1"/>
<Button
android:id="@+id/times"
android:text="x"
style="@style/Button1"/>
<Button
android:id="@+id/min"
android:text="-"
style="@style/Button1"/>
<Button
android:id="@+id/plus"
android:text="+"
style="@style/Button1"/>
Name: Chaitra.M
Reg No: 9824037018
<Button
android:id="@+id/equal"
android:text="="
style="@style/Button1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
package com.example.calculator;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Number Buttons
Button num0 = findViewById(R.id.num0);
Button num1 = findViewById(R.id.num1);
Button num2 = findViewById(R.id.num2);
Button num3 = findViewById(R.id.num3);
Button num4 = findViewById(R.id.num4);
Button num5 = findViewById(R.id.num5);
Button num6 = findViewById(R.id.num6);
Button num7 = findViewById(R.id.num7);
Button num8 = findViewById(R.id.num8);
Button num9 = findViewById(R.id.num9);
// Operation Buttons
Button on = findViewById(R.id.on);
Button off = findViewById(R.id.off);
Name: Chaitra.M
Reg No: 9824037018
Button ac = findViewById(R.id.ac);
Button del = findViewById(R.id.del);
Button div = findViewById(R.id.div);
Button times = findViewById(R.id.times);
Button min = findViewById(R.id.min);
Button equal = findViewById(R.id.equal);
Button plus = findViewById(R.id.plus);
Button point = findViewById(R.id.point);
// Screen (TextView)
TextView screen = findViewById(R.id.screen);
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CalacutorProject"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.CalacutorProject"
parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
]
<item name="colorOnPrimary">@color/white</item>
<!-- secondary brand color-->
<item name="colorOnSecondary">@color/Black</item>
<!-- Status bar color -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
</style>
<style name="Button1">
<item name="android:layout_width">75dp</item>
<item name="android:layout_height">75dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">27dp</item>
<item name="android:gravity">center</item>
<item name="android:padding">10dp</item>
<item name="android:layout_margin">10dp</item>
<item name="android:background">@drawable/shape1</item>
</style>
<style name="Button2">
<item name="android:layout_width">75dp</item>
<item name="android:layout_height">75dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">27dp</item>
<item name="android:gravity">center</item>
<item name="android:padding">10dp</item>
<item name="android:layout_margin">10dp</item>
<item name="android:background">@drawable/shape2</item>
</style>
</resources>
<item name="colorPrimary">@color/Black</item>
<item name="colorPrimaryVariant">@color/Black</item>
<item name="colorOnPrimary">@color/Black</item>
<item name="colorSecondary">@color/Black</item>
<item name="colorSecondaryVariant">@color/Black</item>
<item name="colorOnSecondary">@color/Black</item>
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
</style>
</resources>
Output:
Name: Chaitra.M
Reg No: 9824037018
Result:
Thus to native calculator was developed using Android Studio and the output was
verified.
Name: Chaitra.M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
Name: Chaitra.M
Reg No: 9824037018
Design view code file name: activity main.xml
<?xmlversion="1.0"encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/flashlightButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/off" />
</RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
flashlightButton = findViewById(R.id.flashlightButton);
flashlightButton.setOnClickListener(v -> {
try {
if (isFlashlightOn)
{ turnOffFlashlight();
} else {
turnOnFlashlight();
}
} catch (CameraAccessException e)
{ e.printStackTrace();
}
});
}
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Flashlight"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
Output:
Name: Chaitra.M
Reg No: 9824037018
Result:
Thus to create flashlight app was developed using Android Studio and the output was
verified.
Name: Chaitra.M
Reg No: 9824037018
Ex. No.5 Develop An Android Application To Create A Sending Email
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
<TextView android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:text="Email Subject:"
android:textColor="#0F9D58" />
<TextView android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText3"
android:layout_alignBottom="@+id/editText3"
android:text="Email Body:"
android:textColor="#0F9D58" />
Output:
Name: Chaitra.M
Reg No: 9824037018
Result:
Thus to create sending email was developed using Android Studio and the output
was verified.
Name: Chaitra.M
Reg No: 9824037018
Ex. No.6 Develop An Android Application To Create A Sending SMS
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Phone Number"
android:id="@+id/editText1"
android:padding="15dp"
android:maxLength="10"
android:inputType="phone"
android:background="@drawable/rect"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:hint="Enter Phone Number"
android:padding="15dp"
android:maxLength="20"
android:inputType="textMultiLine"
android:lines="7"
android:background="@drawable/rect"
android:layout_marginTop="15dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSent"
android:text="Sending SMS"
android:layout_marginTop="30dp"/> Sending
SMS page activity code: rect.xml
package com.example.sms;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnsent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ContextCompat.checkSelfPermission(MainActivity.this,
Name: Chaitra.M
Reg No: 9824037018
Manifest.permission.SEND_SMS)
== PackageManager.PERMISSION_GRANTED) {
sendSMS();
} else {
ActivityCompat.requestPermissions(MainActivity.this, new
String[]{Manifest.permission.SEND_SMS},
100);
}
}
});
}
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SMS"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
Output:
Name: Chaitra.M
Reg No: 9824037018
Result:
Thus to Create sending SMS was developed using Android Studio and the output
was verified.
Name: Chaitra.M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program:
Name: Chaitra.M
Reg No: 9824037018
Design view code file name: activity main.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:gravity="center_horizontal"
android:text="Press The Back Button of Your Phone."
android:textSize="30dp" android:textStyle="bold" />
</RelativeLayout>
package com.example.alertdialog;
import android.content.DialogInterface;
import android.os.Bundle; import
androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
builder.setTitle("Alert !");
builder.setCancelable(false);
builder.setPositiveButton("Yes",
Name: Chaitra.M
Reg No: 9824037018
(DialogInterface.OnClickListener) (dialog, which) -> {
finish();
});
builder.setNegativeButton("No", (DialogInterface.OnClickListener) (dialog, which) -> {
dialog.cancel();
});
Output:
Result:
Thus to Create analog dialog was developed using Android Studio and the output
was verified.
Name: Chaitra.M
Reg No: 9824037018
Date:
Aim:
Procedure
5. Insert two Button control. Give the id as “buttonOk” and “buttonReset” and give text
property as “OK” and “Reset” respectively.
Step 2: Open java -> MainActivity.java and write the code needed for button “OK” and
“Reset” event triggering (refer program).
Program: