Mad Record PDF
Mad Record PDF
INFORMATION TECHNOLOGY
RECORD NOTEBOOK
Name:__________________________________________________
Register No:_____________________________________________
Subject Code/Title:_______________________________________
Year/Semester:__________________________________________
1
BONAFIDE CERTIFICATE
2
CONTENTS
6 Develop an application to
connect to a web service and to
retrieve data with HTTP.
9 Develop an application by
integrating Google maps
3
EX. NO: 1
STUDY AND INSTALLATION OF FLUTTER/KOTLIN MULTI-
Date:
PLATFORM ENVIRONMENT
Aim:
To Study and installation of Flutter/Kotlin multi-platform environment.
PROCEDURE:
(i)To develop an android application using Kotlin, we need a Android application
development IDE such as Android Studio.
(ii)Android Studio is an IDE that allows us to develop application at single platform. We can
download Android Studio set from Android Studio official link Download Android Studio.
Before installing Android Studio on our machine, we must have Java installed. Look a
reference here https://www.javatpoint.com/how-to-set-path-in-java to set path of JDK.
After download Android Studio, run its setup and install it. To install follow the instructions.
4
Click Next to proceed.
5
Check the component which we want to install.
6
Select the maximum size of RAM to use emulator instances.
7
OUTPUT:
Result:
Thus , the installation of Flutter/Kotlin multi-platform environment was executed
successfully.
8
EX. NO: 2
DEVELOP AN APPLICATION THAT USES WIDGETS, GUI
Date: COMPONENTS, FONTS, AND COLORS
Aim:
To develop an application that uses Widgets, GUI components, Fonts,and
Colors.
Java file:
packagecom.lab.guicomponents;
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.view.Menu; public class
MainActivity extends Activity {
@Override protected void onCreate(Bundle
savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override publicbooleanonCreateOptionsMenu(Menu
menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu); return
true;
}
}
XML file
9
<LinearLayoutxmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical” android:padding=”20dip”>
<EditText
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Edit Text”/> <Button
android:id=”@+id/btn1”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Button”/> <CheckBox
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Checkbox”/>
<RadioButton
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Radio Button”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Green Color”
android:textColor=”#00ff00”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Red Color”
10
android:textColor=”#ff0000”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Blue Color”
android:textColor=”#0000ff”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Size 10”
android:textColor=”#000000”
android:textSize=”10dip”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Size 15”
android:textColor=”#000000”
android:textSize=”15dip”/> <TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Size 20”
android:textColor=”#000000”
android:textSize=”20dip”/> <TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Size 50”
11
android:textColor=”#000000”
android:textSize=”50dip”/>
</LinearLayout>
OUTPUT:
Result:
Thus the application that uses Widgets, GUI components, Fonts,and Colors
executed successfully.
EX NO: 3
12
Date:
DEVELOP A NATIVE CALCULATOR APPLICATION
Aim:
To Develop a native calculator application.
JAVA CODE
package com.example.rating; import
androidx.appcompat.app.AppCompatActivity; import
android.annotation.SuppressLint; import
android.os.Bundle; import android.view.View;
import android.widget.Button; import
android.widget.EditText; import
android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText firstnum,secondnum;
TextView r;
Button bt;
Button bts; Button
btm; double a,b,c;
@SuppressLint(“MissingInflatedId”)
@Override protected void onCreate(Bundle
savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firstnum=(EditText) findViewById(R.id.first);
secondnum=(EditText) findViewById(R.id.second);
bt=(Button) findViewById(R.id.buttonadd);
13
bts=(Button) findViewById(R.id.buttonsub);
btm=(Button) findViewById(R.id.buttonmul);
r=(TextView) findViewById(R.id.result);
bt.setOnClickListener(new View.OnClickListener() {
r.setText(“Sub=”+c);
} });
btm.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v)
{ a=Double.parseDouble(firstnum.getText().toString());
b=Double.parseDouble(secondnum.getText().toString());
c=a*b;
r.setText(“Mul=”+c);
}
});
}
}
14
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”
android:layout_centerHorizontal=”true” tools:context=”.MainActivity">
<TextView android:id=”@+id/textview1”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentTop=”true”
android:layout_centerHorizontal=”true”
android:text=”Enter number 1”
android:textSize=”18sp” />
<EditText android:id=”@+id/first”
android:text=”one”
android:minHeight=”48dp”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/textview1”
android:layout_alignParentTop=”false”
android:layout_alignParentRight=”false”
android:layout_centerHorizontal=”true”
android:ems=”10”
android:inputType=”number” />
<TextView
15
android:id=”@+id/textView2”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/first”
android:layout_centerHorizontal=”true”
android:text=”Enter Number 2”
android:textSize=”18sp”/> <EditText
android:id=”@+id/second”
android:text=”two”
android:minHeight=”48dp”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/textView2”
android:layout_centerHorizontal=”true”
android:ems=”10”
android:inputType=”number” />
<Button android:id=”@+id/buttonadd”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/second”
android:layout_centerHorizontal=”true”
android:text=”Add”/> <Button
android:id=”@+id/buttonsub”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/buttonadd
16
”
android:layout_centerHorizontal=”true”
android:id=”@+id/buttonmul”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/buttonsub
android:layout_centerHorizontal=”true”
android:id=”@+id/result”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/buttonmul
android:layout_centerHorizontal=”true”
android:textSize=”24sp” />
</RelativeLayout>
17
OUTPUT:
Result:
Thus, the native calculator application was executed successfully.
18
EX NO: 4 DEVELOP A GAMING APPLICATION THAT USES 2-D
ANIMATIONS AND GESTURES
Date:
Aim:
To develop a gaming application that uses 2-D animation and gestures.
JAVA CODE
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import
android.view.View; import
android.view.animation.Animation; import
android.view.animation.AnimationUtils; import
android.widget.Button; import
android.widget.ImageView;
public class MainActivity extends AppCompatActivity
{ ImageVie imageView;
Button blinkBTN, rotateBTN, fadeBTN, moveBTN, slideBTN, zoomBTN, stopBTN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageview);
blinkBTN = findViewById(R.id.BTNblink);
rotateBTN = findViewById(R.id.BTNrotate);
fadeBTN = findViewById(R.id.BTNfade);
moveBTN = findViewById(R.id.BTNmove);
19
slideBTN = findViewById(R.id.BTNslide);
zoomBTN = findViewById(R.id.BTNzoom);
stopBTN = findViewById(R.id.BTNstop);
blinkBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add blink animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink_animation);
imageView.startAnimation(animation);
}
});
rotateBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add rotate animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_animation);
imageView.startAnimation(animation);
}
});
fadeBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add fade animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_animation);
imageView.startAnimation(animation);
20
}
})
moveBTN.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
// To add move animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move_animation);
imageView.startAnimation(animation);
}
});
slideBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add slide animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_animation);
imageView.startAnimation(animation);
}
});
zoomBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_animation);
imageView.startAnimation(animation);
}
});
stopBTN.setOnClickListener(new View.OnClickListener() {
@Override
21
public void onClick(View v) {
imageView.clearAnimation();
}
});
}
}
XML CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainActivity">
<ImageView
android:id="@+id/imageview"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:contentDescription="@string/app_name"
android:src="@drawable/gfgimage" />
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageview"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">
22
<!--To start the blink animation of the image-->
<Button android:id="@+id/BTNblik
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/blink"
android:textColor="@color/white" />
<!--To start the rotate animation of the image-->
<Button
android:id="@+id/BTNrotate"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/clockwise"
android:textColor="@color/white" />
<!--To start the fading animation of the image-->
<Button
android:id="@+id/BTNfade"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
23
android:padding="3dp"
android:text="@string/fade"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/linear1"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">
<!--To start the move animation of the image-->
<Button
android:id="@+id/BTNmove"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/move"
android:textColor="@color/white" />
<!--To start the slide animation of the image-->
<Button
android:id="@+id/BTNslide"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
24
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp” android:text="@string/slide"
android:textColor="@color/white" />
Result:
Thus the gaming application that uses 2-D animation and gestures was executed
successfully.
26
Aim:
To develop a movie rating application (similar to IMDB).
JAVA CODE
package com.example.ra; import
android.graphics.Color; import
android.graphics.PorterDuff; import
android.graphics.drawable.LayerDrawable; import
androidx.appcompat.app.AppCompatActivity;
//import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import
android.view.View; import
android.widget.RatingBar; import
android.widget.TextView;
public class MainActivity extends AppCompatActivity {
RatingBar rt; @Override protected void
onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//binding MainActivity.java with activity_main.xml file rt
= (RatingBar) findViewById(R.id.ratingBar);
//finding the specific RatingBar with its unique ID
LayerDrawable stars=(LayerDrawable)rt.getProgressDrawable();
//Use for changing the color of RatingBar
stars.getDrawable(2).setColorFilter(Color.YELLOW,
PorterDuff.Mode.SRC_ATOP);
} public void Call(View
v) {
<androidx.coordinatorlayout.widget.CoordinatorLayout
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”
android:fitsSystemWindows=”true” tools:context=”.MainActivity”>
<RatingBar android:id=”@+id/ratingBar”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginTop=”104dp”
android:background=”#00AA00”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
tools:layout_constraintLeft_creator=”1”
tools:layout_constraintRight_creator=”1”
tools:layout_constraintTop_creator=”1” />
28
<TextView android:id=”@+id/textView”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Rate Me!!!”
android:textColor=”@android:color/background_dark”
android:textSize="30sp” android:textStyle=”bold|
italic” tools:layout_editor_absoluteX=”127dp”
tools:layout_editor_absoluteY=”28dp” />
<TextView android:id=”@+id/textView2”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginTop=”148dp”
android:textColorHint=”#FF0000”
android:textSize=”24sp”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintTop_toBottomOf=”@+id/ratingBar”
tools:layout_constraintRight_creator=”1”
tools:layout_constraintLeft_creator=”1” />
<Button android:id=”@+id/button”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginBottom=”50dp”
android:layout_marginTop=”50dp”
android:background=”@android:color/
holo_red_dark”
29
android:onClick=”Call”
android:text=”Submit”
android:textColor=”@android:color/ba
ckground_light”
android:textStyle=”bold|italic”
app:layout_constraintBottom_toTopOf
=”@+id/textView2”
app:layout_constraintLeft_toLeftOf=”
parent”
app:layout_constraintRight_toRightOf
=”parent”
app:layout_constraintTop_toBottomOf
=”@+id/ratingBar”
tools:layout_constraintBottom_creator
=”1”
tools:layout_constraintLeft_creator=”1
tools:layout_constraintRight_creator=”
1”
tools:layout_constraintTop_creator=”1
” />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
OUTPUT:
30
Result:
Thus the movie rating application (similar to IMDB) was executed successfully.
EX NO: 6
DEVELOP AN APPLICATION TO CONNECT TO A
Date: WEB SERVICE AND TO RETRIEVE DATA WITH
HTTP
Aim:
31
To develop an application to connect to a web service and to retrieve data with
HTTP.
JAVA CODE:
package com.example.webv; import
android.os.Bundle; import android.webkit.WebView;
import android.webkit.WebViewClient; import
androidx.appcompat.app.AppCompatActivity; public
class MainActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle
savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the WebView by its unique ID
WebView webView = findViewById(R.id.web);
// loading https://www.geeksforgeeks.org url in the WebView.
webView.loadUrl(“https://www.geeksforgeeks.org”); //
this will enable the javascript.
webView.getSettings().setJavaScriptEnabled(true);
// WebViewClient allows you to handle
// onPageFinished and override Url loading.
webView.setWebViewClient(new WebViewClient());
}
}
XML CODE:
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent” android:layout_height=”match_parent”
32
tools:context=”com.gfg.android.examplekotlin.MainActivity”>
<!-- unique ID of WebView -- >
<WebView android:id=”@+id/web”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
tools:layout_editor_absoluteX=”8dp”
tools:layout_editor_absoluteY=”8dp” />
</RelativeLayout>
AndroidManifest.xml
OUTPUT:
33
Result:
Thus ,the application to connect to a web service and to retrieve data with
HTTP was executed successfully.
34
EX NO: 7 DEVELOP A SIMPLE SHOPPING APPLICATION
Date:
Aim:
To develop a simple shopping application.
JAVA CODE:
package com.example.grocerylist.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import com.example.grocerylist.Database.Entity.GroceryItems;
import com.example.grocerylist.R;
import com.example.grocerylist.UI.GroceryViewModel;
import com.example.grocerylist.databinding.GroceryadapterBinding;
35
@Override public GroceryViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
GroceryadapterBinding binding =
GroceryadapterBinding.inflate(LayoutInflater.from(parent.getContext()), parent,
false);
return new GroceryViewHolder(binding);
}
@Override
public int getItemCount() {
return list.size();
}
@Override
public void onBindViewHolder(GroceryViewHolder holder, int position)
{ GroceryItems currentPosition = list.get(position);
holder.binding.txtItemName.setText(currentPosition.getItemName());
holder.binding.txtItemPrice.setText(String.valueOf(currentPosition.getItemPrice()));
holder.binding.txtItemQuantity.setText(String.valueOf(currentPosition.getItemQuantit
y()));
holder.binding.ibDelete.setOnClickListener(v -> viewModel.delete(currentPosition));
if (position == list.size() - 1) {
int totalCost = 0;
for (int i = 0; i < list.size(); i++)
{ totalCost +=
list.get(i).getItemPrice();
36
}
holder.binding.txtItemTotalCost.setVisibility(View.VISIBLE);
holder.binding.txtTotalCostTitle.setVisibility(View.VISIBLE);
holder.binding.txtItemTotalCost.setText(String.valueOf(totalCost));
}
}
static class GroceryViewHolder extends RecyclerView.ViewHolder
{ private final GroceryadapterBinding binding;
XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="@drawable/adapter1">
37
android:layout_height="53dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="17dp"
android:fontFamily="@font/rokkitt"
android:text="@string/itemName"
android:textColor="@color/white"
android:textSize="35sp"
app:layout_constraintBottom_toTopOf="@+id/txtT
otalCostTitle"
app:layout_constraintEnd_toStartOf="@+id/txtItemQuantity"
app:layout_constraintStart_toEndOf="@+id/cbItemCheck"
app:layout_constraintTop_toTopOf="parent" />
<!-- To display item quantity -->
<TextView
android:id="@+id/txtItemQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="34dp"
android:layout_marginRight="34dp"
android:layout_marginBottom="9dp"
android:text="@string/itemQuantity"
android:textColor="@color/white"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="@+id/txtItemName"
app:layout_constraintEnd_toStartOf="@+id/txtItemPrice"
38
app:layout_constraintStart_toEndOf="@+id/txtItemName"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
android:layout_width="wrap_conten
t"
android:layout_height="wrap_conten
t"
android:layout_marginTop="26dp"
android:layout_marginEnd="22dp"
android:layout_marginRight="22dp"
android:layout_marginBottom="26dp"
android:text="@string/itemPrice"
android:textColor="@color/white"
android:textSize="25sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/txtItemTotalCost"
app:layout_constraintEnd_toStartOf="@+id/ibDelete"
app:layout_constraintStart_toEndOf="@+id/txtItemQuantity"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
39
<CheckBox
android:id="@+id/cbItemCheck" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="29dp"
android:layout_marginLeft="29dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="@color/white"
android:shadowColor="@color/black"
app:layout_constraintBaseline_toBaselineOf="@+id/txtItemName"
app:layout_constraintEnd_toStartOf="@+id/txtItemName"
app:layout_constraintStart_toStartOf="parent" />
40
<TextView
android:id="@+id/txtItemTotalCost"
android:layout_width="100dp"
android:layout_height="60dp"
android:background="@drawable/adapter2"
android:padding="8dp"
android:paddingLeft="12dp"
<!-- This text view is used to add statement for total cost -->
<TextView
android:id="@+id/txtTotalCostTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="77dp"
android:layout_marginLeft="77dp"
android:layout_marginEnd="149dp"
android:layout_marginRight="149dp"
android:layout_marginBottom="16dp"
android:text="@string/totalCostTitle"
android:textColor="@color/white"
android:textSize="20dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/txtItemTotalCost"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
41
OUTPUT:
Result:
Thus the simple shopping application was executed successfully.
42
EX NO: 8
DESIGN A WEB SERVER SUPPORTING PUSH
Date:
NOTIFICATIONS
Aim:
To design a web server supporting push notification.
JAVA CODE:
.setContentTitle(“Notification”)
.setContentText(“this is noti”);
NotificationManager notificationManager=(NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0,mbuilder.build());
}
});
}
}
XML:
xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
xmlns:app=”http://schemas.android.com/apk/res-auto”
android:layout_width=”match_parent”
android:layout_height=”match_parent” tools:context=”.MainActivity’>
<Button android:id=”@+id/click”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:contentDescription=”button”
44
android:layout_centerInParent=”true”
android:text=”notification”
/>
</RelativeLayout>
OUTPUT:
Result:
Thus the design a web server supporting push notification was executed
successfully.
45
EX NO: 9
DEVELOP AN APPLICATION BY INTEGRATING GOOGLE
Date:
MAPS
Aim:
JAVA CODE:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import
com.google.android.gms.maps.OnMapReadyCallback; import
com.google.android.gms.maps.SupportMapFragment; import
com.google.android.gms.maps.model.LatLng; import
com.google.android.gms.maps.model.MarkerOptions;
46
// Add a marker in Sydney and move the camera
LatLng mayiladuthurai = new LatLng(11.1035, 79.6521);
mMap.addMarker(new MarkerOptions()
.position(mayiladuthurai).title("Marker in Mayiladuthurai"));
mMap.mov
eCamera(CameraUpdateFactory.newLatLng(mayiladuthurai));
}
}
XML CODE:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
47
OUTPUT:
Result:
48
Date:
Aim:
To develop a mini project using flutter.
Program :
package com.example.db;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle; import
android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; import
android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener {
EditText Rollno, Name, Marks;
Button Insert, Delete, Update, View, ViewAll;
SQLiteDatabase db;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Rollno = (EditText) findViewById(R.id.Rollno);
Name = (EditText) findViewById(R.id.Name);
Marks = (EditText) findViewById(R.id.Marks);
Insert = (Button) findViewById(R.id.Insert);
Delete = (Button) findViewById(R.id.Delete);
Update = (Button) findViewById(R.id.Update);
View = (Button) findViewById(R.id.View);
ViewAll = (Button) findViewById(R.id.all);
Insert.setOnClickListener(this);
Delete.setOnClickListener(this);
Update.setOnClickListener(this);
49
View.setOnClickListener(this);
ViewAll.setOnClickListener(this);
// Creating database and table
db = openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE, null);
db.execSQL(“CREAT TABLE IF NOT EXISTS student(rollno VARCHAR,name
VARCHAR, marks VARCHAR);”);
}
50
if (Rollno.getText().toString().trim().length() == 0) {
showMessage("Error", "Please enter Rollno");
return; }
Cursor c = db.rawQuery(“SELECT * FROM student WHERE rollno=’” +
Rollno.getText() + “’”, null);
if (c.moveToFirst()) {
db.execSQL(“UPDATE student SET name=’”" + Name.getText() + “’,marks=’” +
Marks.getText() + ‘ “WHERE rollno=”" + Rollno.getText() + “’”);
showMessage("Success", "Record Modified");
} else {
showMessage("Error", "Invalid Rollno");
}
clearText();
}
// Display a record from the Student table
if (view == View)
if(view == ViewAll)
{
c = db.rawQuery(“SELECT * FROM student”, null);
if(c.getCount()==0)
{
showMessage("Error", "No records found");
return;
}
StringBuffer buffer=new StringBuffer();
while(c.moveToNext())
{
buffer.append("Rollno: "+c.getString(0)+"\n");
buffer.append("Name: "+c.getString(1)+"\n");
buffer.append("Marks: "+c.getString(2)+"\n\n");
}
51
showMessage("Student Details", buffer.toString());
}
}
public void showMessage(String title,String message)
{
Builder builder=new Builder(this);
builder.setCancelable(true); builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
public void clearText()
{
Rollno.setText("");
Name.setText("");
Marks.setText("");
Rollno.requestFocus();
52
53