Mad - Lab PRG 4-10
Mad - Lab PRG 4-10
EX.NO : 4
DATE: 08.08.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml:
<?xml version= “1.0” encoding= “utf-8”?>
<RelativeLayout
xmlns:android= http://schemas.android.com/apk/res/android
android:layout_width= “match_parent”
android:layout_height= “match_parent”>
<ImageView
android:id= “@+id/imageView”
android:layout_width= “match_parent”
android:layout_height= “match_parent”>
</RelativeLayout>
MainActivity.java:
package com.example.prgfour;
import android.app.Activity;
import android.graphics.*;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
RESULT:
Thus a simple application that draws basic Graphical Primitives on the screen
is developed and executed successfully.
DEVELOP AN APPLICATION THAT MAKES
USE OF RSS FEED
EX.NO : 5
DATE : 17.08.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java:
package com.example.prgfive;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
RESULT:
Thus a simple Android application that use of RSS Feed is developed and
executed successfully.
DEVELOP AN APPLICATION THAT IMPLEMENTS
MULTITHREADING
EX.NO : 6
DATE : 25.08.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="50dp"
android:layout_gravity="center"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load Image 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load image 2" />
</LinearLayout>
MainActivity.java:
package com.example.prgsix;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
Result:
Thus a simple Android application that implements Multithreading is developed and
executed successfully.
DEVELOP AN APPLICATION THAT
EX.NO : 7
DATE : 30.08.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:checked="false"
android:onClick="OnToggleClicked" />
</LinearLayout>
MainActivity.java:
package com.example.prgseven;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;
package com.example.prgseven;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.widget.Toast;
Result:
Thus a simple Android application that create alarm clock is developed and executed
successfully.
DEVELOP AN APPLICATION
USING WIDGETS
EX.NO : 8
DATE : 04.09.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is a basic Widget App"
android:textSize="25sp"
android:layout_centerInParent="true"
android:paddingStart="30dp"
tools:ignore="RtlSymmetry" />
</RelativeLayout>
new_app_widget.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Widget.Prgeight.AppWidget.Container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.Prgeight.AppWidgetContainer">
<TextView
android:id="@+id/appwidget_text"
style="@style/Widget.Prgeight.AppWidget.InnerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:contentDescription="Thamizh"
android:text="Thamizh"
android:textColor="#FF000000"
android:textSize="24sp"
android:textStyle="bold|italic" />
</RelativeLayout>
MainActivity.java:
package com.example.prgeight;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity
{
@Override
protected void onCreate( Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
NewAppWidget.java:
package com.example.prgeight;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.widget.RemoteViews;
/**
* Implementation of App Widget functionality.
*/
public class NewAppWidget extends AppWidgetProvider
{
static void updateAppWidget(Context context, AppWidgetManager
appWidgetManager, int appWidgetId)
{
CharSequence widgetText = context.getString
(R.string.appwidget_text);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews
(context.getPackageName(), R.layout.new_app_widget);
views.setTextViewText(R.id.appwidget_text, widgetText);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
@Override
public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds)
{
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds)
{
updateAppWidget(context, appWidgetManager,
appWidgetId);
}
}
@Override
public void onEnabled(Context context) {
// Enter relevant functionality for when the first widget is created
}
@Override
public void onDisabled(Context context)
{
// Enter relevant functionality for when the last widget is disabled
}
}
OUTPUT:
Result:
Thus a simple Android application Using Widgets is developed and executed
successfully.
IMPLEMENT AN APPLICATION THAT
WRITES TO THE SD CARD
EX.NO : 9
DATE : 07.09.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Write Data"
android:textSize="30sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Read data"
android:textSize="30sp" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Clear"
android:textSize="30sp" />
</LinearLayout>
MainActivity.java:
package com.example.prgnine;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
Result:
Thus a simple Android application that writes data to SD Card is developed and
executed successfully.
IMPLEMENT AN APPLICATION THAT CREATES AN
EX.NO : 10
DATE : 13.09.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
MainActivity.java:
package com.example.prgten;
import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.app.AlertDialog;
import android.widget.Toast;
Result:
Thus a simple Android application that creating an alert upon receiving a message is
developed and executed successfully.
DEVELOP AN APPLICATION THAT MAKES
USES OF DATABASE
EX.NO : 11
DATE : 22.09.2023
AIM:
PROCEDURE:
STEP 2 : Go to File -> New -> New project -> change file name -> next.
STEP 4 : Choose -> Empty activity-> Next -> Main activity -> Finish.
STEP 5 : Go to activity_main.xml page type clear and type the necessary coding.
STEP 8 : Select Tools ->Android -> AVD Manager or click the AVD Manager icon.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="20dp"
android:text="Student Details"
android:textSize="30sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="110dp"
android:text="Enter Rollno:"
android:textSize="20sp" />
<EditText
android:id="@+id/Rollno"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="100dp"
android:inputType="number"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="160dp"
android:text="Enter Name:"
android:textSize="20sp" />
<EditText
android:id="@+id/Name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="150dp"
android:inputType="text"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="210dp"
android:text="Enter Marks:"
android:textSize="20sp" />
<EditText
android:id="@+id/Marks"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="200dp"
android:inputType="number"
android:textSize="20sp" />
<Button
android:id="@+id/Insert"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="300dp"
android:text="Insert"
android:textSize="30dp" />
<Button
android:id="@+id/Delete"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="300dp"
android:text="Delete"
android:textSize="30dp" />
<Button
android:id="@+id/Update"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="400dp"
android:text="Update"
android:textSize="30dp" />
<Button
android:id="@+id/View"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="400dp"
android:text="View"
android:textSize="30dp" />
<Button
android:id="@+id/ViewAll"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="500dp"
android:text="View All"
android:textSize="30dp" />
</AbsoluteLayout>
MainActivity.java:
package com.example.prgeleven;
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;
Result:
Thus a simple Android application that makes use of database is developed and
executed successfully.