Professional Documents
Culture Documents
Mad
Mad
BACHELOR OF ENGINEERING
IN
Submitted By:
Faculty Incharge:
Mrs. RAJANI G N
Associate Professor, Department of Information Science & Engineering
Siddaganga Institute of Technology, Tumakuru-572103.
Academic Year: -2023-24
ACKNOWLEDGEMENT
With reverential pranams, we express our sincere gratitude and salutations to His Holiness Dr.Sree
Sree Sivakumara Swamigalu and His Holiness Sree Sree Siddalinga Swamigalu of Sree Siddaganga
Mutt for their unlimited blessings.
First and foremost, we wish to express our deep sincere feelings of gratitude to our institution,
Siddaganga Institute of Technology, for providing us an opportunity for completing our project
successfully.
We express our kind thanks to Sr. Shivakumariah, CEO and Joint Secretary, SSES and Dr. S.V
Dinesh, Principal, Siddaganga Institute of Technology, Tumakuru for their encouragement towards
student attitude.
We express our heartfelt thanks to Dr. R. Aparna, Professor and Head, Department of
Information Science and Engineering, Siddaganga Institute of Technology, Tumakuru for her
suggestions and advice.
We express our heart full gratitude and humble thanks to our faculty in charge, Mrs. Rajani G N,
Assistant Professor, Department of Information Science and Engineering, Siddaganga Institute of
Technology, Tumakuru for guiding and facilitating to complete our Mobile Application laboratory
successfully.
We are conscious of the fact that we have received cooperation in many ways from the Teaching,
Technical and supporting staffs of the Department of Information Science and Engineering and we are
grateful to all for their cooperation.
We express heartfelt gratitude to our parents and friends for their constant moral support and
encouragement throughout this work.
-Ravindra Savadatti
-Srikanta Murthy N G
-Suhas K N
SIDDAGANGA INSTITUTE OF TECHNOLOGY
TUMAKURU-572103
Department of Information Science and Engineering
CERTIFICATE
This is to certify that the laboratory programs and the open ended experiment entitled “Farmer’s E-
commerce Application” has been successfully carried out by Ravindra Savadatti bearing USN
1SI22IS074, Srikanta Murthy N G bearing USN 1SI22IS103 and, Suhas K N bearing USN
1SI22IS105 at Siddaganga Institute of Technology Tumkur, in partial fulfillment of the
requirements for 4 t h Semester of Bachelor of Engineering in Information Science and
Engineering of affiliated to Visvesvaraya Technological University, Belgaum, during the academic
year 2023-2024. It is certified that all corrections/suggestions indicated have been incorporated in the
report deposited in departmental library. The lab work has been approved as it satisfies the academic
requirements in respect of lab work carried out in 4th semester prescribed for the Bachelor of
Engineering Degree.
_______________ _________________
Mrs. Rajani G N, Dr. R Aparna,
Assistant Professor, Professor and Head,
Dept. Of ISE, Dept. Of ISE,
SIT Tumakur. SIT Tumakur.
TABLE OF CONTENTS
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schem
as.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="211dp"
android:layout_height="61dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.445"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.723" />
<TextView
android:id="@+id/textView2"
android:layout_width="328dp"
android:layout_height="84dp"
android:text=" SIDDAGANGA INSTITUTE OF"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.401" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TECHNOLOGY"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.466"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.436" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="An autonoumus institue affiliated to AICTE"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.499" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="108dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.559" />
<ImageView
android:id="@+id/imageView"
android:layout_width="126dp"
android:layout_height="152dp"
android:layout_marginStart="128dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.131"
app:srcCompat="@drawable/img" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.lab1;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
Button btn = findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
}
});
}
package com.example.lab1;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
Toast.LENGTH_SHORT).show();
Output:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://
schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FDFBF7"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="253dp"
android:layout_height="99dp"
android:textAlignment="center"
android:textSize="21dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.101"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.166" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="120dp"
android:layout_height="115dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.945"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.121"
app:srcCompat="@drawable/logo" />
<View
android:id="@+id/view"
android:layout_width="412dp"
android:layout_height="235dp"
android:background="#4444"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.032" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RAMESH GOVIND"
android:textAlignment="center"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.625" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STUDENT - ISE"
android:textAlignment="center"
android:textSize="18dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.467"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.684" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="52dp"
android:textAlignment="center"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.757" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.798" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.476"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.838" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="103dp"
android:layout_height="148dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.48"
app:srcCompat="@drawable/user" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.myapplication;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
Type.systemBars());
systemBars.bottom);
return insets;
});
Output:
XML Design:
XML Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="209dp"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="113dp"
android:layout_marginRight="113dp"
android:layout_marginBottom="610dp"
android:text="Simple Calci"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="117dp"
android:layout_marginRight="117dp"
android:layout_marginBottom="418dp"
android:ems="10"
android:inputType="textPersonName"
android:text=""
android:textColorHighlight="#FFFFFF" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="116dp"
android:layout_marginRight="116dp"
android:layout_marginBottom="504dp"
android:ems="10"
android:inputType="textPersonName"
android:text=""
android:textColorHighlight="#FFFFFF" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="261dp"
android:layout_marginRight="261dp"
android:layout_marginBottom="213dp"
android:onClick="add"
android:text="ADD"
android:textStyle="bold"
app:backgroundTint="#E8F381" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="261dp"
android:layout_marginRight="261dp"
android:layout_marginBottom="105dp"
android:onClick="mul"
android:text="MUL"
app:backgroundTint="#A1FAA4" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="68dp"
android:layout_marginRight="68dp"
android:layout_marginBottom="107dp"
android:onClick="div"
android:text="DIV"
app:backgroundTint="#E6C28C" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="70dp"
android:layout_marginRight="70dp"
android:layout_marginBottom="214dp"
android:onClick="sub"
android:text="SUB"
app:backgroundTint="#ECA9A9" />
<TextView
android:id="@+id/tv1"
android:layout_width="86dp"
android:layout_height="61dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="144dp"
android:layout_marginRight="144dp"
android:layout_marginBottom="310dp"
android:text="0"
android:textSize="36sp" />
</RelativeLayout>
JAVA Code:
package com.example.simplecalculator;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
EditText e1,e2;
TextView tv;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
setContentView(R.layout.activity_main);
e1 =(EditText) findViewById(R.id.editText1);
e2 = (EditText)findViewById(R.id.editText2);
int a1=Integer.parseInt(e1.getText().toString());
int a2=Integer.parseInt(e2.getText().toString());
int result=a1+a2;
tv.setText(""+result);
int a1=Integer.parseInt(e1.getText().toString());
int result=a1-a2;
tv.setText(""+result);
int a1=Integer.parseInt(e1.getText().toString());
int result=a1*a2;
tv.setText(""+result);
float a1=Integer.parseInt(e1.getText().toString());
float result=a1/a2;
tv.setText(""+result);
Output:
1. FIRST ACTIVITY:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FIRST ACTIVITY"
android:textSize="34sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.208" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="first"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.447"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.669" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.intentapplication;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
systemBars.bottom);
return insets;
});
Intent(getApplicationContext(),secondactivity.class);
startActivity(intent1);
2. SECOND ACTIVITY:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".secondactivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SECOND ACTIVITY"
android:textSize="34sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.208" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="first"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.447"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.669" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.intentapplication;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_second);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
systemBars.bottom);
return insets;
});
Intent(getApplicationContext(),MainActivity.class);
startActivity(intent1);
Output:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http:
//schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#A116BA"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.311" />
<ImageView
android:id="@+id/imageView"
android:layout_width="146dp"
android:layout_height="146dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.068"
app:srcCompat="@drawable/logo" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.405" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.456" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="contineo"
android:text="Contineo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.549" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="telephone"
android:text="Contact"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.824" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="website"
android:text="Visit website"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.641" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-mail: principal@sit.ac.in"
android:textColor="#000000"
android:textStyle="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.505"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.917" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.96" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="location"
android:text="Location"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.733" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.implicitintentapplication;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.util.Locale;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
systemBars.bottom);
return insets;
});
Uri webpage =
Uri.parse("https://www.bing.com/ck/a?!&&p=805a898862d5c926JmltdHM9MTcxNjQyMjQ
wMCZpZ3VpZD0wZWZjZjZhYS0yYWJlLTZkN2EtMDQxZC1lNTQyMmI3NzZjNTAmaW5zaWQ9NTIzOA&p
tn=3&ver=2&hsh=3&fclid=0efcf6aa-2abe-6d7a-041d-
e5422b776c50&psq=sit+tumkur+contineo&u=a1aHR0cHM6Ly9zaW1zLnNpdC5hYy5pbi9wYXJl
bnRzLw&ntb=1");
startActivity(webIntent);
Uri webpage =
Uri.parse("https://www.bing.com/ck/a?!&&p=53952f5ebf9b4deeJmltdHM9MTcxNjQyMjQ
wMCZpZ3VpZD0wZWZjZjZhYS0yYWJlLTZkN2EtMDQxZC1lNTQyMmI3NzZjNTAmaW5zaWQ9NTI0Mg&p
tn=3&ver=2&hsh=3&fclid=0efcf6aa-2abe-6d7a-041d-
e5422b776c50&psq=sit+tumkur+&u=a1aHR0cDovL3d3dy5zaXQuYWMuaW4vaHRtbC9ob21lLmh0
bWw&ntb=1");
startActivity(webIntent1);
phoneNumber));
startActivity(callIntent);
Uri.encode(address));
startActivity(intentWithAddress);
Output:
On successful SIGN UP proceed to the next Login activity. Here the user should
SIGN IN using the Username and Password created during signup activity. If the
Username and Password are matched, then navigate to the next activity which
displays a message saying, “Successful Login” or else display a toast message
saying “Login Failed”. The user is given only two attempts and after that display a
toast message saying, “Failed Login Attempts” and disable the SIGN IN button.
Use Bundle to transfer information from one activity to another.
1. SIGNUP ACTIVITY:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<View
android:id="@+id/view"
android:layout_width="412dp"
android:layout_height="731dp"
android:background="#DDB375"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="112dp"
android:elegantTextHeight="true"
android:hint="E-mail"
android:text="SignUP"
android:textColor="#0419DA"
android:textSize="34sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.483"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/view"
app:layout_constraintVertical_bias="0.012" />
<EditText
android:id="@+id/editTextEmailAddress"
android:layout_width="263dp"
android:layout_height="59dp"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:textColorHint="#000000"
app:layout_constraintBottom_toBottomOf="@+id/view"
app:layout_constraintEnd_toEndOf="@+id/view"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/view"
app:layout_constraintVertical_bias="0.386" />
<EditText
android:id="@+id/editTextPassword"
android:layout_width="264dp"
android:layout_height="54dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColorHint="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/view"
app:layout_constraintHorizontal_bias="0.479"
app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintTop_toTopOf="@+id/view"
app:layout_constraintVertical_bias="0.515" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign in"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.466"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.714" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.signup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.util.regex.Pattern;
Button signupbtn;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
signupbtn.setOnClickListener(new View.OnClickListener() {
@Override
if (!isValidPassword(password)) {
return;
i.putExtra("email", email);
i.putExtra("password", password);
startActivity(i);
});
if(password.length()<8)
return false;
if(!lowerCase.matcher(password).matches())
return false;
if(!upperCase.matcher(password).matches())
return false;
if(!number.matcher(password).matches())
return false;
if(!special_char.matcher(password).matches())
return false;
return true;
2. LOGIN ACTIVITY:
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".login_activity">
<View
android:id="@+id/view2"
android:layout_width="412dp"
android:layout_height="732dp"
android:background="#DDB375"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="#0419DA"
android:textSize="34sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.463"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.151" />
<EditText
android:id="@+id/editTextTextEmailAddress2"
android:layout_width="257dp"
android:layout_height="53dp"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:textColorHint="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.383" />
<EditText
android:id="@+id/editTextTextPassword2"
android:layout_width="259dp"
android:layout_height="54dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColorHint="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/view2" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.688" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.signup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
Button login_btn;
int counter=2;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_login);
emailEditText=(EditText)findViewById(R.id.editTextTextEmailAddress2);
passwordEditText=(EditText)findViewById(R.id.editTextTextPassword2);
login_btn=(Button)findViewById(R.id.button2);
String registeredEmail=getIntent().getStringExtra("email");
String registeredpassword=getIntent().getStringExtra("password");
login_btn.setOnClickListener(new View.OnClickListener()
@Override
String email=emailEditText.getText().toString();
String password=passwordEditText.getText().toString();
if(registeredEmail.equals(email) &&
registeredpassword.equals(password))
Intent i = new
Intent(getApplicationContext(),loginsuccessful_activity.class);
startActivity(i);
else
Toast.makeText(login_activity.this, "Invalid
Credentials", Toast.LENGTH_SHORT).show();
counter--;
if(counter==0)
Toast.LENGTH_SHORT).show();
login_btn.setEnabled(false);
});
• Size: 38dp
• Text: “Login Successful”
• Center-Align
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#05CEE8"
tools:context=".loginsuccessful_activity">
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#DFE69B"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login Successful"
android:textColor="#000000"
android:textSize="34sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="@+id/view3"
app:layout_constraintEnd_toEndOf="@+id/view3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/view3" />
<ImageView
android:id="@+id/imageView"
android:layout_width="259dp"
android:layout_height="177dp"
app:layout_constraintBottom_toBottomOf="@+id/view3"
app:layout_constraintEnd_toEndOf="@+id/view3"
app:layout_constraintHorizontal_bias="0.519"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/view3"
app:layout_constraintVertical_bias="0.258"
app:srcCompat="@drawable/logo" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.signup;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_loginsuccessful);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets) -> {
Insets systemBars =
insets.getInsets(WindowInsetsCompat.Type.systemBars());
return insets;
});
Output:
XML Design:
XML Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="142dp"
android:layout_marginRight="142dp"
android:layout_marginBottom="287dp"
<TextView
android:id="@+id/textView"
android:layout_width="319dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="49dp"
android:layout_marginTop="93dp"
android:layout_marginEnd="43dp"
android:layout_marginBottom="460dp"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="38dp" />
</RelativeLayout>
JAVA Code:
package com.example.myapplication;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
Button wallpaperChange;
Timer mytimer;
Drawable drawable;
WallpaperManager wpm;
int prev=1;
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
mytimer=new Timer();
wpm = WallpaperManager.getInstance(this);
wallpaperChange=(Button)findViewById(R.id.button1);
wallpaperChange.setOnClickListener(new View.OnClickListener() {
@Override
setwallpaper();
});
wait.",Toast.LENGTH_LONG).show();
mytimer.schedule(new TimerTask() {
@Override
if(prev==1) {
drawable = getResources().getDrawable(R.drawable.i1);
prev = 2;
else if(prev==2) {
drawable = getResources().getDrawable(R.drawable.i1);
prev=3;
else if(prev==3) {
drawable = getResources().getDrawable(R.drawable.i3);
prev=4;
else if(prev==4) {
drawable = getResources().getDrawable(R.drawable.i4);
prev=1;
try {
wpm.setBitmap(wallpaper);
catch(IOException e)
e.printStackTrace();
},0,30000);
Output:
Program-7: Write a program to create an activity with two buttons START and
STOP. On pressing of the START button, the activity must start the counter by
displaying the numbers from One and the counter must keep on counting until
the STOP button is pressed. Display the counter value in a TextView control.
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="207dp"
android:background="#BF8126"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView"
android:layout_width="325dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:text="COUNTER APPLICATION"
android:textAlignment="center"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.113" />
<Button
android:id="@+id/button2"
android:layout_width="101dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:text="STOP"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.822"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.774" />
<Button
android:id="@+id/button"
android:layout_width="103dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:text="START"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.191"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.774" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:text="0"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.counterapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
TextView txtCounter;
Button btn_start,btn_stop;
int count=0;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtCounter= (TextView)findViewById(R.id.textView2);
btn_start =(Button)findViewById(R.id.button);
btn_stop=(Button)findViewById(R.id.button2);
btn_start.setOnClickListener(new View.OnClickListener() {
@Override
customHandler.postDelayed(updateTimerThread,0);
});
btn_stop.setOnClickListener(new View.OnClickListener() {
@Override
customHandler.removeCallbacks(updateTimerThread);
});
@Override
txtCounter.setText(""+count);
customHandler.postDelayed(this,1000);
count++;
};
Output:
Program-8: Create an activity like a phone dialler with CALL and SAVE buttons. On
pressing the CALL button, it must call the phone number and on pressing the
SAVE button it must save the number to the phone contacts.
XML Design:
XML Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Button11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#4CAF50"
tools:context=".MainActivity">
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="168dp"
android:layout_marginBottom="237dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="8" />
<Button
android:id="@+id/Button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="286dp"
android:layout_marginBottom="163dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="*" />
<Button
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="101dp"
android:layout_marginBottom="51dp"
android:backgroundTint="#CDDC39"
android:text="Save" />
<Button
android:id="@+id/callBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="223dp"
android:layout_marginBottom="52dp"
android:backgroundTint="#F44336"
android:text="Call" />
<Button
android:id="@+id/clearBtn12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="168dp"
android:layout_marginBottom="162dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="0" />
<Button
android:id="@+id/Button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="286dp"
android:layout_marginBottom="236dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="7" />
<Button
android:id="@+id/Button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="49dp"
android:layout_marginBottom="236dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="9" />
<EditText
android:id="@+id/phoneNumberEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="163dp"
android:layout_marginBottom="560dp"
android:ems="10"
android:hint="Phone Number"
android:inputType="phone"
android:onClick="inputNumber" />
<Button
android:id="@+id/clearBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="48dp"
android:layout_marginBottom="558dp"
android:backgroundTint="#E91E63"
android:text="Clear" />
<Button
android:id="@+id/Button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="49dp"
android:layout_marginBottom="162dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="#" />
<Button
android:id="@+id/Button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="288dp"
android:layout_marginBottom="399dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="1" />
<Button
android:id="@+id/Button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="287dp"
android:layout_marginBottom="313dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="4" />
<Button
android:id="@+id/Button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="168dp"
android:layout_marginBottom="313dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="5" />
<Button
android:id="@+id/Button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="48dp"
android:layout_marginBottom="313dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="6" />
<Button
android:id="@+id/Button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="170dp"
android:layout_marginBottom="398dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="2" />
<Button
android:id="@+id/Button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="49dp"
android:layout_marginBottom="399dp"
android:backgroundTint="#4CAF50"
android:onClick="inputNumber"
android:text="3" />
<TextView
android:id="@+id/textView"
android:layout_width="305dp"
android:layout_height="47dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="46dp"
android:layout_marginTop="35dp"
android:layout_marginEnd="59dp"
android:layout_marginBottom="648dp"
android:textAlignment="center"
android:textSize="24sp" />
</RelativeLayout>
JAVA Code:
package com.example.callandsaveapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
EditText phoneNumberEditText;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
phoneNumberEditText = findViewById(R.id.phoneNumberEditText);
clearBtn = findViewById(R.id.clearBtn);
callBtn = findViewById(R.id.callBtn);
saveBtn = findViewById(R.id.saveBtn);
clearBtn.setOnClickListener(new View.OnClickListener() {
@Override
phoneNumberEditText.setText("");
});
callBtn.setOnClickListener(new View.OnClickListener() {
@Override
String phoneNumber =
phoneNumberEditText.getText().toString();
intent.setData(Uri.parse("tel:" + phoneNumber));
startActivity(intent);
});
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
String phoneNumber =
phoneNumberEditText.getText().toString();
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.PHONE,
phoneNumber);
startActivity(intent);
});
phoneNumberEditText.setText(phoneNumber + digit);
Output:
Program-9: Write an android program to demonstrate scroll view and list view.
(List view should array adapter. The adapter should use array list of companies.
Each item in the list view should have company name, company address and its
annual revenue.)
XML Design:
XML Code:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ListView
android:id="@+id/listview"
android:layout_width="409dp"
android:layout_height="729dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
JAVA Code:
package com.example.scrollapplication;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
String fruits[] = {
"LIST OF COMPANIES:",
million",
$322,467 million",
$302,089 million",
$282,836 million",
$276,711 million",
};
@Override
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
android.R.layout.simple_list_item_1, fruits);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
});
Output:
XML Design:
XML Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>
JAVA Code:
package com.example.scrollapplication;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
i.setBackgroundDrawable(new BitmapDrawable(bg));
paint.setColor(Color.BLUE);
paint.setTextSize(50);
Output: