0% found this document useful (0 votes)
7 views60 pages

Android Lab 197

The document outlines the steps to create Android applications, including system requirements, setting up Android Studio, and coding practices for different practicals. It details the setup process for Android Studio on various operating systems and provides sample code for creating user interfaces and managing application activities. Additionally, it includes examples of XML layouts and Java classes for implementing Android lifecycle and user interface elements.

Uploaded by

LAKKAD OM.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views60 pages

Android Lab 197

The document outlines the steps to create Android applications, including system requirements, setting up Android Studio, and coding practices for different practicals. It details the setup process for Android Studio on various operating systems and provides sample code for creating user interfaces and managing application activities. Additionally, it includes examples of XML layouts and Java classes for implementing Android lifecycle and user interface elements.

Uploaded by

LAKKAD OM.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Enrollment No.

: 202303103510197

Practical-1
Aim :
Create an Android application by setting appropriate application launcher icon .

Code :
Step 1 - System Requirements

You will be delighted, to know that you can start your Android application development on
either of the following operating systems −

 Microsoft® Windows® 10/8/7/Vista/2003 (32 or 64-bit)


 Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)
 GNOME or KDE desktop
Second point is that all the required tools to develop Android applications are open source
and can be downloaded from the Web. Following is the list of software's you will need
before you start your Android application programming.

 Java JDK5 or later version


 Java Runtime Environment (JRE) 6
 Android Studio

Step 2 - Setup Android Studio

Android Studio is the official IDE for android application [Link] works based on
IntelliJ IDEA, You can download the latest version of android studio from
Android Studio 2.2 Download, If you are new to installing Android Studio on
windows,you will find a file, which is named as android-studio-bundle-143.3101438-
[Link] just download and run on windows machine according to android studio
wizard guideline.
If you are installing Android Studio on Mac or Linux, You can download the latest version
from Android Studio Mac Download,or Android Studio Linux Download, check the
instructions provided along with the downloaded file for Mac OS and Linux. This tutorial
will consider that you are going to setup your environment on Windows machine having
Windows 8.1 operating system.

So let's launch Android [Link],Make sure before launch Android Studio, Our Machine
should required installed Java JDK. To install Java JDK,take a references of Android
environment setup

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


1
Enrollment No. : 202303103510197

Once you launched Android Studio, its time to mention JDK7 path or later version in android
studio installer.

Below the image initiating JDK to android SDK


UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
2
Enrollment No. : 202303103510197

Need to check the components, which are required to create applications, below the
image has selected Android Studio, Android SDK, Android Virtual Machine
and performance(Intel chip).

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


3
Enrollment No. : 202303103510197

Need to specify the location of local machine path for Android studio and Android SDK,
below the image has taken default location of windows 8.1 x64 bit architecture.

Need to specify the ram space for Android emulator by default it would take 512MB of
local machine RAM.

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


4
Enrollment No. : 202303103510197

At final stage, it would extract SDK packages into our local machine, it would take a while
time to finish the task and would take 2626MB of Hard disk space.

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


5
Enrollment No. : 202303103510197

After done all above steps perfectly, you must get finish button and it gonna be open
android studio project with Welcome to android studio message as shown below

You can start your application development by calling start a new android studio project. in
a new installation frame should ask Application name, package information and location of
the project.

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


6
Enrollment No. : 202303103510197

Practical-2
Aim :
Create an Android application that will demonstrate the use of

each:

a. Android Lifecycle

b. User interface elements

c. Layouts.

Code :
(activity_main.xml)

<RelativeLayout xmlns:app="[Link]
xmlns:tools="[Link]
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/purple_200"
xmlns:android="[Link]

<Button

android:id="@+id/cons"
android:backgroundTint="@color/black"
android:text="Constraint Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<Button

android:id="@+id/grid"
android:backgroundTint="@color/black"
android:text="Grid Layout"
android:layout_width="match_parent"
android:layout_below="@+id/cons"

android:layout_height="wrap_content" />

<Button

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


7
Enrollment No. : 202303103510197

android:id="@+id/frame" android:text="Frame
Layout"
android:backgroundTint="@color/black"
android:layout_below="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<Button

android:id="@+id/linear" android:text="Linear
Layout"
android:backgroundTint="@color/black"
android:layout_below="@+id/frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<Button

android:id="@+id/table"
android:backgroundTint="@color/bl
ack" android:text="Table Layout"
android:layout_below="@+id/linear
"
android:layout_width="match_pare
nt"
android:layout_height="wrap_conte
nt" />

<RadioButton

android:id="@+id/
radioButton"
android:layout_width="200d
p"
android:layout_height="100d
p"
android:layout_below="@id/t
able"
android:layout_marginTop="-
22dp"
android:text="RadioButton"
/>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


8
Enrollment No. : 202303103510197

<Switch

android:id="@+id/switch1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Switch" android:layout_below="@id/radioButton"/>

<ImageView
android:id="@+id/imageView" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/vvc"
android:layout_below="@id/switch1"/>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="This
is TextView \n Copyright-Bs"
android:layout_centerHorizontal="true"
android:layout_below="@id/imageView"/>
</RelativeLayout>

[[Link]]

package [Link];

import [Link];import
[Link];

import [Link];
import
[Link];import
[Link];

public class MainActivity extends AppCompatActivity {Button


constraint, grid, frame, linear, table; @Override

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
setContentView([Link].activity_main);

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


9
Enrollment No. : 202303103510197

constraint = (Button)findViewById([Link]);grid =
(Button)findViewById([Link]); frame =
(Button)findViewById([Link]); linear =
(Button)findViewById([Link]); table =
(Button)findViewById([Link]);

[Link](new [Link]()
{@Override public void onClick(View view) {
startActivity(new Intent([Link],[Link]));
}
});
[Link](new [Link]()
{@Override public void onClick(View view) {
startActivity(new Intent([Link],[Link]));
}
});
[Link](new [Link]()
{@Override public void onClick(View view) {
startActivity(new Intent([Link],[Link]));
}
});
[Link](new [Link]() {@Override
public void onClick(View view) {
startActivity(new Intent([Link],[Link]));
}
});
[Link](new [Link]()
{@Override public void onClick(View view) {
startActivity(new Intent([Link],[Link]));
}
});
}
}

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


10
Enrollment No. : 202303103510197

[[Link]]

package [Link];
import [Link];

import [Link];
public class Constraint extends AppCompatActivity
{@Override

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
setContentView([Link].activity_constraint);
}
}

[[Link]]

package [Link];
import [Link];

import
[Link];public
class Frame extends AppCompatActivity { @Override

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
setContentView([Link].activity_frame);
}
}

[[Link]]

package [Link];
import [Link];

import
[Link];public class
Grid extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState); setContentView([Link].activity_grid);
}

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


11
Enrollment No. : 202303103510197

[[Link]]

package [Link];
import [Link];

import
[Link];public
class Linear extends AppCompatActivity { @Override

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
setContentView([Link].activity_linear);
}
}

[[Link]]

package [Link];
import [Link];

import [Link];public
class Table extends AppCompatActivity { @Override

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
setContentView([Link].activity_table);
}
}

[activity_constraint.xml]

<?xml version="1.0" encoding="utf-8"?>

<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="[Link]">
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
12
Enrollment No. : 202303103510197

<TextView android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView2" />

<TextView android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="337dp"
android:text="Good Morning"

app:layout_constraintBottom_toTopOf="@+id/textView1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</[Link]>

[activity_frame.xml]

<FrameLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="[Link]
android">
<TextView
android:text="Hello"
android:gravity="center"
android:textSize="50dp"

android:textColor="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</FrameLayout>

[activity_grid.xml]

<GridLayout
android:orientation="vertical"
android:layout_height="match_parent"
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
13
Enrollment No. : 202303103510197

android:layout_width="match_parent"
android:rowCount="2"
android:columnCount="2"
xmlns:android="[Link]
<TextView
android:text="Hello"
android:textSize="20dp"
android:layout_row="0"
android:layout_column="0"
android:layout_margin="10d
p" />
<TextView
android:text="Helllo1"
android:textSize="20dp"
android:layout_row="0"
android:layout_column="1"
android:layout_margin="10dp
" />
<TextView
android:text="hello 2"
android:textSize="20dp"
android:layout_row="1"

android:layout_column="0"
android:layout_margin="10d
p" />

<TextView
android:text="hello
noob"android:textSize="20dp
" android:layout_row="1"
android:layout_column="1"
android:layout_margin="10d
p" />
</GridLayout>

[activity_linear.xml]

<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="[Link]
android">

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


14
Enrollment No. : 202303103510197

<TextView
android:text="Hello Good morning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<ImageView
android:src="@mipmap/ic_launcher_round"
android:scaleType="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

[activity_table.xml]

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
xmlns:android="[Link]
android">

<TableRow>

<TextView
android:text="Hello"
android:padding="5dip"
android:textSize="50dp"
/>
<TextView android:text="hello1"
android:padding="5dip"
android:textSize="50dp"/>
</TableRow>
<TableRow>

<TextView android:text="hello"
android:padding="5dip"
android:textSize="50dp"
/>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


15
Enrollment No. : 202303103510197

<TextView android:text="hello
noob"android:padding="5dip"
android:textSize="50dp"/>
</TableRow>
</TableLayout>

Output:

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


16
Enrollment No. : 202303103510197

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


17
Enrollment No. : 202303103510197

Practical-3
Aim :
Design an activity which contains three fragments horizontally.

First fragment contains the gallery of institute, second fragment contains available courses. If
user selects a particular course from the list then third Fragment displays the description of
selected course from the second fragment.

Code :
 [Link]

package [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];

public class MainActivity extends AppCompatActivity {

FrameLayout frameLayout;

TabLayout tabLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

frameLayout = (FrameLayout) findViewById([Link]);


tabLayout = (TabLayout) findViewById([Link]);

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


18
Enrollment No. : 202303103510197

getSupportFragmentManager().beginTransaction().replace([Link],new
FirstFragment())
.addToBackStack(null)
.commit();

[Link](new [Link]() {
@Override
public void onTabSelected([Link] tab) {
Fragment fragment=null;
switch ([Link]()){
case 0:
fragment = new FirstFragment();
break;
case 1:
fragment = new SecondFragment();
break;
case 2:
fragment = new ThirdFragment();
break;
}

getSupportFragmentManager().beginTransaction().replace([Link],
fragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.commit();

@Override
public void onTabUnselected([Link] tab) {

@Override
public void onTabReselected([Link] tab) {

}
});
}
}

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


19
Enrollment No. : 202303103510197

 [Link]

package [Link];

import [Link];

import [Link];

import [Link];
import [Link];
import [Link];

/**
* A simple {@link Fragment} subclass.
* Use the {@link FirstFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class FirstFragment extends Fragment {

// TODO: Rename parameter arguments, choose names that match


// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";

// TODO: Rename and change types of parameters


private String mParam1;
private String mParam2;

public FirstFragment() {
// Required empty public constructor
}

/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment FirstFragment.
*/
// TODO: Rename and change types and number of parameters
public static FirstFragment newInstance(String param1, String param2) {

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


20
Enrollment No. : 202303103510197

FirstFragment fragment = new FirstFragment();


Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return [Link]([Link].fragment_first, container, false);
}
}

 [Link]

package [Link];

import [Link];

import [Link];

import [Link];
import [Link];
import [Link];

/**
* A simple {@link Fragment} subclass.
* Use the {@link SecondFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SecondFragment extends Fragment {
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
21
Enrollment No. : 202303103510197

// TODO: Rename parameter arguments, choose names that match


// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";

// TODO: Rename and change types of parameters


private String mParam1;
private String mParam2;

public SecondFragment() {
// Required empty public constructor
}

/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SecondFragment.
*/
// TODO: Rename and change types and number of parameters
public static SecondFragment newInstance(String param1, String param2) {
SecondFragment fragment = new SecondFragment();
Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
22
Enrollment No. : 202303103510197

// Inflate the layout for this fragment


return [Link]([Link].fragment_second, container, false);
}
}

 [Link]

package [Link];

import [Link];

import [Link];

import [Link];
import [Link];
import [Link];

/**
* A simple {@link Fragment} subclass.
* Use the {@link ThirdFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ThirdFragment extends Fragment {

// TODO: Rename parameter arguments, choose names that match


// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";

// TODO: Rename and change types of parameters


private String mParam1;
private String mParam2;

public ThirdFragment() {
// Required empty public constructor
}

/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
23
Enrollment No. : 202303103510197

* @return A new instance of fragment ThirdFragment.


*/
// TODO: Rename and change types and number of parameters
public static ThirdFragment newInstance(String param1, String param2) {
ThirdFragment fragment = new ThirdFragment();
Bundle args = new Bundle();
[Link](ARG_PARAM1, param1);
[Link](ARG_PARAM2, param2);
[Link](args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return [Link]([Link].fragment_third, container, false);
}
}

 Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">

<[Link]

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


24
Enrollment No. : 202303103510197

android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#075E34"
app:tabIndicatorColor="@color/white"
app:tabSelectedTextColor="@color/white">

<[Link]
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First" />

<[Link]
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second" />

<[Link]
android:id="@+id/tab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third" />

</[Link]>

<FrameLayout
android:id="@+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


25
Enrollment No. : 202303103510197

 Fragment_first.xml

<?xml version="1.0" encoding="utf-8"?>


<FrameLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FirstFragment">

<!-- TODO: Update blank fragment layout -->


<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24dp"
android:textAlignment="center"
android:text="First" />

</FrameLayout>

 Fragment_second.xml

<?xml version="1.0" encoding="utf-8"?>


<FrameLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondFragment">

<!-- TODO: Update blank fragment layout -->


<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24dp"
android:textAlignment="center"
android:text="Second" />
</FrameLayout>

 Fragment_third.xml

<?xml version="1.0" encoding="utf-8"?>


<FrameLayout xmlns:android="[Link]
xmlns:tools="[Link]

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


26
Enrollment No. : 202303103510197

android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ThirdFragment">

<!-- TODO: Update blank fragment layout -->


<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24dp"
android:textAlignment="center"
android:text="Third" />
</FrameLayout>

Output :

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


27
Enrollment No. : 202303103510197

Practical-4
Aim :
Create an application that have two activities:

- Registration of student

- Login

Registration of student activity have “Registration” button and “Login” button. If user clicks
on “Registration” button registration details will be stored in database by using SQLite.

After successful registration, Toast will be displayed with message “Registration done
successfully” and redirect to Login activity.

If user click on “Login” button Login activity will be opened.

Login activity check for user id and password.

On successful login go to home screen and display user data on home page.

Registrations of students contain student name, address, contact number, email Id and date of
birth.

Code :
 [Link]

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
28
Enrollment No. : 202303103510197

EditText username,password,repassword;
Button signup, signin;
DBHelper DB;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_main);

username = (EditText) findViewById([Link]);


password = (EditText) findViewById([Link]);
repassword = (EditText) findViewById([Link]);
signin = (Button) findViewById([Link]);
signup = (Button) findViewById([Link]);
DB = new DBHelper(this);

[Link](new [Link]() {
@Override
public void onClick(View view) {
String user = [Link]().toString();
String pass = [Link]().toString();
String repass = [Link]().toString();

if([Link]("")||[Link]("")||[Link](""))
[Link]([Link], "Please Enter all the Fields",

Toast.LENGTH_SHORT).show();
else
{
if([Link](repass))
{
Boolean checkuser = [Link](user);
if (checkuser==false)
{
Boolean insert = [Link](user,pass);
if(insert==true)
{
[Link]([Link], "Registered Successfully",

Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(),[Link]);
startActivity(intent);

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


29
Enrollment No. : 202303103510197

}
else
{
[Link]([Link], "Registration Failed",

Toast.LENGTH_SHORT).show();
}
}
else
{
[Link]([Link], "User already exists! Please Sign-In",
Toast.LENGTH_SHORT).show();
}
}
else
{
[Link]([Link], "Repassword in Not matching Password!",
Toast.LENGTH_SHORT).show();
}
}
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),[Link]);
startActivity(intent);
}
});
}
}

 [Link]

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
30
Enrollment No. : 202303103510197

import [Link];

public class DBHelper extends SQLiteOpenHelper {

public static final String DBNAME = "[Link]";

public DBHelper(Context context) {


super(context, "[Link]", null,1);
}

@Override
public void onCreate(SQLiteDatabase MyDB) {
[Link]("create Table users(username TEXT primary key, password TEXT)");
}

@Override
public void onUpgrade(SQLiteDatabase MyDB, int i, int i1) {
[Link]("drop Table if exists users");
}

public Boolean insertionData (String username, String password)


{
SQLiteDatabase MyDB = [Link]();
ContentValues contentValues = new ContentValues();
[Link]("username",username);
[Link]("password",password);
long result = [Link]("users",null,contentValues);
if(result==-1) return false;
else
return true;
}

public Boolean checkusername (String username)


{
SQLiteDatabase MyDB = [Link]();
Cursor cursor = [Link]("Select * from users where username = ?",new
String[]{username} );
if([Link]()>0)
return true;
else
return false;
}

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


31
Enrollment No. : 202303103510197

public Boolean checkusernamepassword (String username, String password)


{
SQLiteDatabase MyDB = [Link]();
Cursor cursor = [Link]("Select * from users where username = ? and
password = ?",new String[]{username,password} );
if([Link]()>0)
return true;
else
return false;
}
}

 [Link]

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class LoginActivity extends AppCompatActivity {

EditText username1,password1;
Button bunlogin;
DBHelper DB;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_login);

username1 = (EditText) findViewById([Link].username1);


password1 = (EditText) findViewById([Link].password1);
bunlogin = (Button) findViewById([Link].bunsignin1);
DB = new DBHelper(this);

[Link](new [Link]() {
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
32
Enrollment No. : 202303103510197

@Override
public void onClick(View view) {

String user = [Link]().toString();


String pass = [Link]().toString();

if([Link]("")||[Link](""))
{
[Link]([Link], "Please Enter all the Fields",

Toast.LENGTH_SHORT).show();
}
else
{
Boolean checkuserpass = [Link](user,pass);

if([Link](true))
{
[Link]([Link], "Sign In Successfully",

Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(),[Link]);
startActivity(intent);
}
else
{
[Link]([Link],"InvalidCredential",Toast.LENGTH_SHO
RT).show();
}
}

}
});
}
}

 [Link]

package [Link];

import [Link];

import [Link];

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


33
Enrollment No. : 202303103510197

import [Link];
import [Link];
import [Link];
import [Link];

public class HomeActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_home);
}
}

 Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
>

<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:hint="Username" />

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginTop="50dp"
android:layout_below="@id/username"
/>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


34
Enrollment No. : 202303103510197

<EditText
android:id="@+id/repassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Retype Password"
android:layout_marginTop="50dp"
android:layout_below="@id/password"
/>

<Button
android:id="@+id/bunsignup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Resigter"
android:layout_marginTop="50dp"
android:layout_below="@+id/repassword"
/>

<Button
android:id="@+id/bunsignin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Existiing User! Can goto Sign-Page"
android:layout_marginTop="10dp"
android:layout_below="@+id/bunsignup"
/>
</RelativeLayout>

 Activity_login.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
tools:context=".LoginActivity">

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


35
Enrollment No. : 202303103510197

<EditText
android:id="@+id/username1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:hint="Username" />

<EditText
android:id="@+id/password1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginTop="50dp"
android:layout_below="@id/username1"
/>

<Button
android:id="@+id/bunsignin1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password1"
android:layout_marginTop="50dp"
android:text="Sign-In" />

</RelativeLayout>

 Activity_home.xml

<?xml version="1.0" encoding="utf-8"?>


<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeActivity">

</[Link]>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


36
Enrollment No. : 202303103510197

Output :

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


37
Enrollment No. : 202303103510197

Practical-5
Aim :
Create an application that will play a media file.

Code :
 [Link]

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link]; import [Link];

import [Link];

public class MainActivity extends AppCompatActivity implements

[Link] {

String path;
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
38
Enrollment No. : 202303103510197

MediaPlayer mediaPlayer; ImageButton play; Boolean isPlaying = false; int pos = -1;

@Override

protected void onCreate(Bundle savedInstanceState) { [Link](savedInstanceState);


setContentView([Link].activity_main);

mediaPlayer = new MediaPlayer(); play = findViewById([Link]);

path = getExternalFilesDir(Environment.DIRECTORY_MUSIC).getPath();

ImageButton prev = findViewById([Link]); ImageButton next =


findViewById([Link]);

RecyclerView recyclerView = findViewById([Link]);

[Link](new LinearLayoutManager(this));

List<String> songsList = new ArrayList<>(); File directory = new File(path);

File[] files = [Link](); if (files != null) {

for (File file : files) { [Link]([Link]());

PlaylistAdapter adapter = new PlaylistAdapter(this, songsList);

[Link](this); [Link](adapter);

[Link](view -> { if (isPlaying) {

[Link](); isPlaying = false;

[Link]([Link].ic_baseline_play_arrow_24);

} else {

[Link](); isPlaying = true;


UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
39
Enrollment No. : 202303103510197

[Link]([Link].ic_baseline_pause_24);

});

[Link](view -> {

if (files != null && pos != -1 && pos != 0) { pos--;

try {

playSong(files[pos].getPath());

[Link](this, "Now Playing: " + files[pos].getName(),

Toast.LENGTH_SHORT).show();

} catch (IOException e) { [Link]();

});

[Link](view -> {

if (files != null && pos != -1 && pos < [Link] - 1) { pos++;

try {

playSong(files[pos].getPath());

[Link](this, "Now Playing: " + files[pos].getName(),

Toast.LENGTH_SHORT).show();

} catch (IOException e) { [Link]();

});

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


40
Enrollment No. : 202303103510197

private void playSong(String path) throws IOException { [Link]();

[Link](path); [Link](); [Link]();

isPlaying = true;

@Override

public void onItemClick(View v, int pos) { TextView textView =


[Link]([Link]);

[Link]([Link].ic_baseline_pause_24); [Link] = pos;

try {

playSong(path + "/" + [Link]().toString()); [Link](this, "Now Playing: "


+ [Link]().toString(),

Toast.LENGTH_SHORT).show();

} catch (IOException e) { [Link]();

 [Link]

package [Link];

import [Link]; import [Link];

import [Link];

import [Link]; import [Link];

import [Link];

import [Link]; import [Link];


UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
41
Enrollment No. : 202303103510197

public class PlaylistAdapter extends [Link]<[Link]> {

private final List<String> songs;

private final LayoutInflater mInflater; private OnItemClickListener listener;

PlaylistAdapter(Context context, List<String> songs)

[Link] = [Link](context); [Link] = songs;

@NonNull @Override

public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)

View view = [Link]([Link], parent, false);

return new ViewHolder(view);

@Override

public void onBindViewHolder(@NonNull ViewHolder holder, int position)

[Link]([Link](position));

@Override

public int getItemCount() { return [Link]();

public void setOnItemClickListener(OnItemClickListener listener) { [Link] = listener;

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


42
Enrollment No. : 202303103510197

public interface OnItemClickListener { void onItemClick(View v, int position);

public class ViewHolder extends [Link] implements

[Link] {

public TextView textView;

public ViewHolder(@NonNull View itemView) { super(itemView);

textView = [Link]([Link]); [Link](this);

@Override

public void onClick(View view) { [Link](view, getAdapterPosition());

 activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<[Link]
xmlns:android="[Link]

xmlns:app="[Link]
xmlns:tools="[Link] android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainActivity">

<[Link] android:id="@+id/rview"
android:layout_width="match_parent" android:layout_height="0dp"
app:layout_constraintHeight_percent="0.85" app:layout_constraintTop_toTopOf="parent"/>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


43
Enrollment No. : 202303103510197

<LinearLayout android:layout_width="match_parent" android:layout_height="0dp"


android:padding="16dp" android:weightSum="3"
app:layout_constraintHeight_percent="0.15"

app:layout_constraintTop_toBottomOf="@+id/rview">

<ImageButton android:id="@+id/prev" android:layout_width="0dp"

android:layout_weight="1"

android:src="@drawable/ic_baseline_skip_previous_24"

android:scaleType="fitCenter"

android:layout_height="match_parent"

android:backgroundTint="@color/black" app:tint="@color/white" />

<ImageButton

android:id="@+id/play"

android:layout_width="0dp"

android:layout_weight="1"

android:src="@drawable/ic_baseline_play_arrow_24"

android:scaleType="fitCenter"

android:layout_height="match_parent"

android:backgroundTint="@color/purple_500" app:tint="@color/white"/>

<ImageButton

android:id="@+id/next"

android:layout_width="0dp" android:layout_weight="1"

android:src="@drawable/ic_baseline_skip_next_24"

android:scaleType="fitCenter"

android:layout_height="match_parent"

android:backgroundTint="@color/black" app:tint="@color/white"/>

</LinearLayout>

</[Link]>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


44
Enrollment No. : 202303103510197

[Link]

<?xml version="1.0" encoding="utf-8"?>

<[Link]
xmlns:android="[Link]

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="16dp" xmlns:app="[Link]

<TextView

app:layout_constraintTop_toTopOf="parent"

android:id="@+id/song"

android:layout_width="match_parent"

android:textAppearance="?android:textAppearanceMedium"
android:layout_height="wrap_content"/>

</[Link]>

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


45
Enrollment No. : 202303103510197

Output :

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


46
Enrollment No. : 202303103510197

Practical-6
Aim :
Create an application to take picture and video using native application.

Code :
 [Link]

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link]; import [Link];

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


47
Enrollment No. : 202303103510197

import [Link];

public class MainActivity extends AppCompatActivity {

Uri videoUri;

@Override

protected void onCreate(Bundle savedInstanceState) { [Link](savedInstanceState);


setContentView([Link].activity_main);

ImageView imageView = findViewById([Link]);

VideoView videoView = findViewById([Link]);

ActivityResultLauncher<Intent> captureResult = registerForActivityResult

( new [Link](), result -> {

if ([Link]() == RESULT_OK) { Intent data = [Link]();

Bitmap image = (Bitmap) [Link]().get("data"); [Link](image);

File path = new

File(getExternalFilesDir(Environment.DIRECTORY_DCIM).getAbsolutePath());

String newfile = [Link]() + ".jpeg"; File file = new File(path, newfile);

try {

FileOutputStream fos = new FileOutputStream(file);

[Link]([Link],90,fos); [Link]();

} catch (FileNotFoundException e) { [Link]();

} catch (IOException e) { [Link]();

});

ActivityResultLauncher<Intent> videoResult = registerForActivityResult( new


[Link](), result -> {
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
48
Enrollment No. : 202303103510197

if ([Link]() == RESULT_OK) { videoUri = [Link]().getData();

File path = new

File(getExternalFilesDir(Environment.DIRECTORY_DCIM).getAbsolutePath());

String newfile = [Link]() + ".mp4"; try {

OutputStream out = new FileOutputStream(newfile);

} catch (FileNotFoundException e) { [Link]();

});

Button capImg = findViewById([Link]); [Link](view -> {

Intent cam = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

[Link](cam);

});

Button recordVid = findViewById([Link]); [Link](view ->


{

Intent recVid = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

[Link](recVid);

});

Button playVideo = findViewById([Link]);

[Link](view -> { [Link](videoUri);

[Link]();

});

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


49
Enrollment No. : 202303103510197

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<[Link]
xmlns:android="[Link]

xmlns:app="[Link]
xmlns:tools="[Link] android:layout_width="match_parent"

android:layout_height="match_parent" tools:context=".MainActivity">

<ImageView android:id="@+id/imgview"

app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_width="200dp" android:layout_height="300dp" />

<VideoView android:id="@+id/vidview" android:layout_width="200dp"

android:layout_height="300dp"

app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgview"/>

<Button

android:id="@+id/captureImg" android:text="capture image"

android:layout_width="match_parent" android:layout_height="wrap_content"

app:layout_constraintTop_toBottomOf="@+id/imgview"
android:backgroundTint="@color/black"/>

<Button

android:id="@+id/recordVideo" android:text="Record Video"

android:layout_width="match_parent" android:layout_height="wrap_content"

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


50
Enrollment No. : 202303103510197

app:layout_constraintTop_toBottomOf="@+id/captureImg"
android:backgroundTint="@color/black"/>

<Button

android:id="@+id/playVideo" android:text="Play Video"

android:layout_width="match_parent" android:layout_height="wrap_content"

app:layout_constraintTop_toBottomOf="@+id/recordVideo"
android:backgroundTint="@color/black"/>

</[Link]>

Output :

Practical-7
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
51
Enrollment No. : 202303103510197

Aim :
Create an application to demonstrate the use of google map.

Code :
 [Link]

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="[Link]

package="[Link]">

<uses-permission android:name="[Link].ACCESS_FINE_LOCATION" />

<uses-permission android:name="[Link].ACCESS_COARSE_LOCATION" />

<uses-permission android:name="[Link]" />

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_round"

android:supportsRtl="true"

android:theme="@style/[Link]">

<!--

TODO: Before you run your application, you need a Google Maps API key. To get one,
follow the directions here:

[Link]

Once you have your API key (it starts with "AIza"), define a new property in your project's
[Link] file (e.g. MAPS_API_KEY=Aiza...), and replace the "YOUR_API_KEY"
string in this file with "${MAPS_API_KEY}".

-->

<meta-data android:name="[Link].API_KEY"

android:value="AIzaSyACZB4Bo2y2LLFNGIhkkTTINV8Rtfa-vmo" />
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
52
Enrollment No. : 202303103510197

<activity android:name=".MapsActivity" android:exported="true"

android:label="@string/title_activity_maps">

<intent-filter>

<action android:name="[Link]" />

<category android:name="[Link]" />

</intent-filter>

</activity>

</application>

</manifest>

 activity_map.xml

<?xml version="1.0" encoding="utf-8"?>

<fragment xmlns:android="[Link]
xmlns:map="[Link]
xmlns:tools="[Link]

android:id="@+id/map"
android:name="[Link]"
android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MapsActivity" />

 [Link]

package [Link];

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


53
Enrollment No. : 202303103510197

import [Link]; import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback


{ private GoogleMap mMap;

private ActivityMapsBinding binding;

@Override

protected void onCreate(Bundle savedInstanceState)

{ [Link](savedInstanceState);

binding = [Link](getLayoutInflater());

setContentView([Link]());

// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)

getSupportFragmentManager()

.findFragmentById([Link]); [Link](this);

@Override

public void onMapReady(GoogleMap googleMap) { mMap = googleMap;

// Add a marker in Gandevi and move the camera


UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
54
Enrollment No. : 202303103510197

LatLng gandevi = new LatLng(20.80766767, 72.999203);

[Link](new MarkerOptions().position(gandevi).title("Marker in Gandevi"));


[Link]([Link](gandevi));

Output :

Practical-8
UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD
55
Enrollment No. : 202303103510197

Aim :
Design and develop an application that have login and

registration form to insert, update, delete and search using firebase. Application should
contain at least two features. (Project)

Output :

SignUp Page (Create)

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


56
Enrollment No. : 202303103510197

Login Page

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


57
Enrollment No. : 202303103510197

Update the Email:

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


58
Enrollment No. : 202303103510197

Remove the User

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


59
Enrollment No. : 202303103510197

UTU/CGPIT/IT or CS/SEM-5/MOBILE APPLICATION DEVELOPMENT/MAD


60

You might also like