PROGRAM 1: Write a program to create an HTML page which has properly aligned paragraphs with
image .
<!DOCTYPE html>
<html>
<head>
<title>Your Page Title</title>
<style>
body {
font-family: Arial, sans-serif;
.container {
width: 80%;
margin: 0 auto;
.content {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
.content p {
flex: 1;
.content img {
width: 400px;
height: auto;
margin-left: 20px;
</style>
</head>
<body>
<div class="container">
<h1>PROGRAM 1</h1>
<div class="content">
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde in,
tempore minus ratione quas hic neque possimus sed suscipit qui commodi
voluptate necessitatibus dolorum voluptatum quo velit veritatis beatae
perspiciatis corporis. Explicabo a vitae eum cupiditate animi ipsa non
quaerat, unde quidem dolorum autem iusto laudantium. Praesentium animi
illum incidunt quas!
</p>
<img src="Screenshot 2024-02-05 180037.png" alt="Placeholder Image" />
</div>
<div class="content">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam
iusto, temporibus ab aliquam at blanditiis ut, odit deserunt delectus
autem doloremque perspiciatis animi facilis quia. Vitae fuga, aperiam
iure quia distinctio alias assumenda eos asperiores! Iste, tempora
voluptatem facilis eaque consequuntur sunt voluptas. Suscipit
perspiciatis consectetur maxime velit reiciendis voluptatem error!
</p>
<img src="Screenshot 2023-08-05 171830.png" alt="Placeholder Image" />
</div>
<div class="content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis,
debitis ea perspiciatis facere neque omnis. Deleniti suscipit
consectetur pariatur quibusdam, rem illum dolor odit obcaecati.
Explicabo id officiis enim perferendis, modi beatae cum odio eum,
repellat cupiditate perspiciatis rerum veniam commodi, eligendi
similique doloremque. Dignissimos quam consectetur nobis. A, explicabo
maiores!
</p>
<img src="Screenshot 2023-08-06 134543.png" alt="Placeholder Image" />
</div>
</div>
</body>
</html>
OUTPUT :
PROGRAM 2: Write a program to create in HTML to create Student feedback form(use
textbox, textarea checkbox radio button select box etc)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Feedback Form</title>
</head>
<body>
<h1>Student Feedback Form</h1>
<form action="#" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="subject">Subject:</label>
<select id="subject" name="subject">
<option value="Mathematics">Mathematics</option>
<option value="Science">Science</option>
<option value="English">English</option>
<option value="History">History</option>
</select><br><br>
<label for="feedback">Feedback:</label><br>
<textarea id="feedback" name="feedback" rows="4" cols="50"></textarea><br><br>
<label>Rate the course:</label><br>
<input type="radio" id="excellent" name="rating" value="excellent">
<label for="excellent">Excellent</label><br>
<input type="radio" id="good" name="rating" value="good">
<label for="good">Good</label><br>
<input type="radio" id="average" name="rating" value="average">
<label for="average">Average</label><br>
<input type="radio" id="poor" name="rating" value="poor">
<label for="poor">Poor</label><br><br>
<label>Check the topics you found most interesting:</label><br>
<input type="checkbox" id="topic1" name="topics" value="topic1">
<label for="topic1">Topic 1</label><br>
<input type="checkbox" id="topic2" name="topics" value="topic2">
<label for="topic2">Topic 2</label><br>
<input type="checkbox" id="topic3" name="topics" value="topic3">
<label for="topic3">Topic 3</label><br><br>
<label for="comments">Any additional comments:</label><br>
<textarea id="comments" name="comments" rows="4" cols="50"></textarea><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
OUTPUT :
PROGRAM 3: Create your class timetable using table tag. Use External CSS to format it.
Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Class Timetable</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Class Timetable</h1>
<table>
<tr>
<th>Time</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
<tr>
<td>8:00 - 9:00</td>
<td>Math</td>
<td>English</td>
<td>Science</td>
<td>History</td>
<td>Physical Education</td>
</tr>
<tr>
<td>9:00 - 10:00</td>
<td>Physics</td>
<td>Chemistry</td>
<td>Math</td>
<td>English</td>
<td>Science</td>
</tr>
<tr>
<td>10:00 - 11:00</td>
<td>History</td>
<td>Physical Education</td>
<td>Physics</td>
<td>Chemistry</td>
<td>Math</td>
</tr>
<!-- Add more rows for remaining hours -->
</table>
</body>
</html>
style.css:
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #dddddd;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #ffffff;
}
tr:nth-child(odd) {
background-color: #f9f9f9;
}
OUTPUT :
PROGRAM 4: Create your resume using HTML tags and then use inline CSS for the
formatting.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Resume</title>
</head>
<body>
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
<h1 style="text-align: center; color: #333;">{VANSH GUPTA}</h1>
<p style="text-align: center; color: #666;">Web Developer</p>
<hr style="border-color: #333;">
<h2 style="color: #333;">Experience</h2>
<div style="margin-bottom: 20px;">
<h3 style="color: #333;">Web Developer - VOIS</h3>
<p style="color: #666;">MAY 2024 - Present</p>
<ul style="list-style-type: circle; color: #666;">
<li>Developed and maintained company website using HTML, CSS, and JavaScript.</li>
<li>Implemented responsive design to ensure compatibility across various devices.</li>
<li>Collaborated with the design team to create visually appealing user interfaces.</li>
</ul>
</div>
<h2 style="color: #333;">Education</h2>
<div>
<h3 style="color: #333;">BE in Computer Science</h3>
<p style="color: #666;">[GCET, JAMMU]</p>
</div>
</div>
</body>
OUTPUT :
PROGRAM 5: Develop a Java Script to display today's date.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display Today's Date</title>
</head>
<body>
<h1>Today's Date</h1>
<p id="date"></p>
<script>
// Get today's date
var today = new Date();
// Extract date, month, and year
var date = today.getDate();
var month = today.getMonth() + 1; // Month starts from 0, so add 1
var year = today.getFullYear();
// Format the date as "DD/MM/YYYY"
var formattedDate = (date < 10 ? '0' : '') + date + '/' + (month < 10 ? '0' : '') + month + '/' +
year;
// Display the date
document.getElementById('date').innerText = formattedDate;
</script>
</body>
</html>
OUTPUT :
PROGRAM 6: Develop simple calculator for addition, subtraction, multiplication and
division operation using JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
</head>
<body>
<h1>Simple Calculator</h1>
<label for="num1">Enter number 1:</label>
<input type="number" id="num1"><br><br>
<label for="num2">Enter number 2:</label>
<input type="number" id="num2"><br><br>
<label for="operator">Select an operator:</label>
<select id="operator">
<option value="add">+</option>
<option value="subtract">-</option>
<option value="multiply">*</option>
<option value="divide">/</option>
</select><br><br>
<button onclick="calculate()">Calculate</button><br><br>
<p id="result"></p>
<script>
function calculate() {
// Get input values
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var operator = document.getElementById('operator').value;
// Perform calculation based on selected operator
var result;
switch (operator) {
case 'add':
result = num1 + num2;
break;
case 'subtract':
result = num1 - num2;
break;
case 'multiply':
result = num1 * num2;
break;
case 'divide':
if (num2 !== 0) {
result=num1/num2;
}
else{
result=”cannot divide by zero!”;
}
break;
default:
result=”invalid operator”;
}
// Display result
document.getElementById('result').innerText = "Result: " + result;
}
</script>
</body>
</html>
OUTPUT :
PROGRAM 7: Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10
and outputs HTML text that displays the resulting values in an HTML table format.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Squares and Cubes</title>
</head>
<body>
<h1>Squares and Cubes</h1>
<div id="output"></div>
<script>
// Function to calculate squares and cubes
function calculateSquaresAndCubes() {
var result = "<table border='1'>";
result += "<tr><th>Number</th><th>Square</th><th>Cube</th></tr>";
// Calculate squares and cubes for numbers from 0 to 10
for (var i = 0; i <= 10; i++) {
var square = i * i;
var cube = i * i * i;
result += "<tr><td>" + i + "</td><td>" + square + "</td><td>" + cube + "</td></tr>";
}
result += "</table>";
// Display the result in the output div
document.getElementById('output').innerHTML = result;
}
// Call the function when the page loads
window.onload = function() {
calculateSquaresAndCubes();
};
</script>
</body>
</html>
OUTPUT :
PROGRAM 8: Write a JavaScript code that displays text "TEXT-GROWING" with increasing font size
in the interval of 100m sin RED COLOR, when the font size reaches 50pt it displays "TEXT
SHRINKING "in BLUE color. Then the font size decreases to 5pt.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Animation</title>
</head>
<body>
<p id="text" style="color: red; font-size: 10pt;">TEXT-GROWING</p>
<script>
var fontSize = 10;
var increasing = true;
var textElement = document.getElementById('text');
function animateText() {
if (increasing) {
fontSize += 1;
textElement.style.fontSize = fontSize + "pt";
if (fontSize >= 50) {
textElement.innerText = "TEXT SHRINKING";
textElement.style.color = "blue";
increasing = false;
}
} else {
fontSize -= 1;
textElement.style.fontSize = fontSize + "pt";
if (fontSize <= 5) {
clearInterval(intervalId);
}
}
}
var intervalId = setInterval(animateText, 100);
</script>
</body>
</html>
OUTPUT :
Practical 9: Develop an android application representing a simple calculator
Program :
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_marginLeft="10pt"
android:layout_marginRight="10pt"
android:layout_marginTop="3pt">
<EditText android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5pt"
android:id="@+id/etNum1"
android:layout_width="match_parent"
android:inputType="numberDecimal">
</EditText><EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5pt"
android:id="@+id/etNum2"
android:layout_width="match_parent"
android:inputType="numberDecimal">
</EditText>
</LinearLayout><LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginTop="3pt"
android:layout_marginLeft="5pt"
android:layout_marginRight="5pt">
<Button android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_weight="1" android:text="+"
android:textSize="15pt"
android:id="@+id/btnAdd">
</Button><Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1" android:text="-"
android:textSize="15pt" android:id="@+id/btnSub">
</Button><Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1" android:text="*"
android:textSize="15pt" android:id="@+id/btnMult">
</Button><Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
CS6611 MOBILE APPLICATION DEVELOPMENT LAB
VVIT Department of Computer Science and Engineering
android:layout_weight="1" android:text="/"
android:textSize="15pt"
android:id="@+id/btnDiv"></Button>
</LinearLayout><TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="5pt"
android:layout_marginRight="5pt"
android:textSize="12pt"
android:layout_marginTop="3pt"
android:id="@+id/tvResult"
android:gravity="center_horizontal">
</TextView>
</LinearLayout>
MainActivity.java coding package CALCU.CALU;
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import
android.view.View.OnClickListener;
import android.widget.Button; import
android.widget.EditText; import
android.widget.TextView;
public class CALCULATORActivity extends Activity implements OnClickListener {
EditText input1;
EditText input2;
Button addition;
Button subtraction;
Button multiplication;
Button division;
TextView tvResult;
String oper = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); input1 =
(EditText) findViewById(R.id.etNum1); input2
= (EditText) findViewById(R.id.etNum2);
addition = (Button) findViewById(R.id.btnAdd);
subtraction = (Button) findViewById(R.id.btnSub);
multiplication = (Button) findViewById(R.id.btnMult);
division = (Button) findViewById(R.id.btnDiv);
tvResult = (TextView) findViewById(R.id.tvResult);
// set a listener
addition.setOnClickListener(this);
subtraction.setOnClickListener(this);
multiplication.setOnClickListener(this);
division.setOnClickListener(this);
@Override
public void onClick(View v) { // TODO Auto-generated method stub
float num1 = 0; float num2 = 0;
float result = 0;
// check if the fields are empty if
(TextUtils.isEmpty(input1.getText().toString())
|| TextUtils.isEmpty(input2.getText().toString())) {
return; }
// read EditText and fill variables with numbers
num1 =
Float.parseFloat(input1.getText().toString());
num2 =
Float.parseFloat(input2.getText().toString());
// defines the button that has been clicked and performs the corresponding operation
// write operation into oper, we will use it later for
output switch (v.getId()) { case R.id.btnAdd:
oper = "+"; result
= num1 + num2;
break; case
R.id.btnSub:
oper = "-"; result
= num1 - num2;
break; case
R.id.btnMult:
oper = "*"; result
= num1 * num2;
break; case
R.id.btnDiv:
oper = "/"; result
= num1 / num2;
break;
default:
break;
// form the output line
tvResult.setText(num1 + " " + oper + " " + num2 + " = " + result);
}
OUTPUT :
Practical 10: Develop an android application for working with notification
ALGORITHM:
1. Create a New Android Project:
• Click New in the toolbar.
• In the window that appears, open the Android folder, select Android Application Project,
and click next.
• Provide the application name and the project name and then finally give the desired
package name.
• Choose a launcher icon for your application and then select Blank Activity and then click
Next
• Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
• click Android Virtual Device Manager from the toolbar.
• In the Android Virtual Device Manager panel, click New.
• Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and
a skin (HVGA is default).
• Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout using buttons, text and ImageView.
4. Creating Second Activity for the Android Application:
5. Click on File -> New -> Activity -> Empty Activity.
6. Type the Activity Name as Second Activity and click Finish button.
7. Run the application.
8. Display the output by clicking the Notify button.
9. Close the Android project.
PROGRAM CODE:
MainActivity.java
package com.example.admin.myapplication;
importandroid.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
27
import android.widget.EditText;
public class MainActivityextends AppCompatActivity
Button notify;
EditTexte;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
notify= (Button) findViewById(R.id.button);
e= (EditText) findViewById(R.id.editText);
notify.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
PendingIntent pending = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
Notificationnoti = new Notification.Builder(MainActivity.this).setContentTitle("New
Message").setContentText(e.getText().toString()).setSmallIcon(R.mipmap.ic_launcher).setContentI
ntent(pending).build();
NotificationManager manager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
noti.flags|= Notification.FLAG_AUTO_CANCEL;
manager.notify(0, noti);
});
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message Form KCET"
android:textSize="30sp" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:layout_gravity="center"
android:text="Notify"
android:textSize="30sp"/>
</LinearLayout
>
Main2Activity.java
package com.example.admin.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
OUTPUT:
Result:
Thus Android Application that that makes use of Notification Manager is developed
and executedsuccessfully.
Practical 11: Develop an android application for connecting to internet and sending e-mail.
ALGORITHM:
1. Create a New Android Project:
• Click New in the toolbar.
• In the window that appears, open the Android folder, select Android Application Project,
and click next.
• Provide the application name and the project name and then finally give the desired
package name.
• Choose a launcher icon for your application and then select Blank Activity and then click
Next
• Provide the desired Activity name for your project and then click Finish.
2. Create a New AVD (Android Virtual Device):
• click Android Virtual Device Manager from the toolbar.
• In the Android Virtual Device Manager panel, click New.
• Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and
a skin (HVGA is default).
• Click Create AVD and Select the new AVD from the Android Virtual Device
Manager and click Start.
3. Design the graphical layout.
4. Run the application.
5. When the application starts alarm sound will be invoked.
6. Stop alarm button is clicked to stop the alarm.
7. Close the Android project.
PROGRAM CODE:
MainActivity.java
package com.example.admin.myapplication;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivityextends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button startBtn = (Button) findViewById(R.id.sendbttn);
startBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendEmail();
});
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {
"muthuramalingam566@gmail.com"
};
String[] CC = {
"ramdurai25@gmail.com"
};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here");
try {
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email...", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There is no email client installed.",
Toast.LENGTH_SHORT).show();
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns: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="com.example.admin.myapplication.MainActivity">
<EditTextandroid:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" /> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignEnd="@+id/editText" /> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText3"
android:layout_below="@+id/editText2"
android:layout_alignRight="@+id/editText2"
android:layout_alignEnd="@+id/editText2" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SEND MAIL"
android:id="@+id/sendbttn"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/editText3"
android:layout_alignStart="@+id/editText3" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recipient"
android:id="@+id/textView"
android:layout_alignBottom="@+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="subject"
android:id="@+id/textView2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message Body"
android:id="@+id/textView3"
android:layout_alignBottom="@+id/editText3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout
>
OUTPUT:
RESULT:
Thus, the program for android application to send an email was executed successfully
PRACTICAL 12 : Develop an android application for working with device camera
Program:
Activity-xml.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity">
<!-- add Camera Button to open the Camera -->
<Button
android:id="@+id/camera_button"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginStart="150dp"
android:text="Camera" />
<!-- add ImageView to display the captured image -->
<ImageView
android:id="@+id/click_image"
android:layout_width="350dp"
android:layout_height="450dp"
android:layout_marginStart="30dp"
android:layout_marginTop="70dp"
android:layout_marginBottom="10dp" />
</RelativeLayout>
MainActivity.java
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.widget.Button;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private static final int pic_id = 123;
Button camera_open_id;
ImageView click_image_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// By ID we can get each component which id is assigned in XML file get Buttons and imageview.
camera_open_id = findViewById(R.id.camera_button);
click_image_id = findViewById(R.id.click_image);
camera_open_id.setOnClickListener(v -> {
// Create the camera_intent ACTION_IMAGE_CAPTURE it will open the camera for capture the image
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Start the activity with camera_intent, and request pic id
startActivityForResult(camera_intent, pic_id);
});
// This method will help to retrieve the image
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Match the request 'pic id with requestCode
if (requestCode == pic_id) {
// BitMap is data structure of image file which store the image in memory
Bitmap photo = (Bitmap) data.getExtras().get("data");
click_image_id.setImageBitmap(photo);
}}}