Mad Lab Programs
Mad Lab Programs
AIM:
ALGORITHM:
STEP 3:Decalre and initailize the button and edittexts in main activity.
MainActivity.Java
package com.college.exercise1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Thread timer;
timer=new Thread()
{
public void run()
{
try
{
sleep(10000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally {
MainActivity.this.finish();
Intent nn = new Intent(MainActivity.this,SecondScreen.class);
startActivity(nn);
}
}
};
timer.start();
}
}
SecondScreen.Java
package com.college.exercise1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second_screen);
}
Activity_Main.XML
<TextView
android:id="@+id/textView3"
android:layout_width="192dp"
android:layout_height="51dp"
android:text="Intent Testing"
android:textColor="@color/colorAccent"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.452"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.141" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="156dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="1. Implicit Intent"
android:textColor="@android:color/holo_green_dark"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.406"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="2. Explicit Intent"
android:textColor="@android:color/holo_green_dark"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.402"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.158" />
</androidx.constraintlayout.widget.ConstraintLayout>
Activity_Second_screen.XML
<TextView
android:id="@+id/textView4"
android:layout_width="217dp"
android:layout_height="40dp"
android:layout_marginStart="112dp"
android:layout_marginLeft="112dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="Second Screen"
android:textColor="@android:color/background_light"
android:textSize="30sp"
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.499"
tools:visibility="visible" />
<Button
android:id="@+id/button"
android:layout_width="221dp"
android:layout_height="64dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="116dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:onClick="ShowWebPage"
android:text="Click Me"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
2.USING CONTROLS
AIM:
ALGORITHM:
STEP 3:Decalre and initailize the button and edittexts in main activity
STEP 5:TO fill the data in the first screen and transfer the data to second screen.
STEP 6:To show the data when we click the botton by using toast.
MainActivity.Java
package com.college.exercise2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
EditText txt1,txt2,txt3;
Spinner sp;
RadioGroup radioSexGroup;
RadioButton radioSexButton;
String degree[] = {"BSc","BCA","BA","BCom","MSc","MCA","MA","MCom"};
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt1 = (EditText)findViewById(R.id.nameTxt);
txt2 = (EditText)findViewById(R.id.fatherTxt);
txt3 = (EditText)findViewById(R.id.dobTxt);
radioSexGroup = (RadioGroup) findViewById(R.id.radioSex);
sp = (Spinner)findViewById(R.id.DegSpinner);
adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,degree);
sp.setAdapter(adapter);
String data = sname + " , " + fname + " , " + dob + " , " + sex + " , " +
deg;
Intent tt = new Intent(MainActivity.this,DataScreen.class);
tt.putExtra("student_info",data);
startActivity(tt);
}
DataScreen.Java
package com.college.exercise2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_screen);
Activity_Data_Screen.XML
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="303dp"
android:onClick="ShowValue"
android:text="Show Data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Activity_Main.XML
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="48dp"
android:layout_marginLeft="48dp"
android:layout_marginTop="68dp"
android:text="Student Name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/nameTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="53dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="154dp"
android:text="Father Name:"
app:layout_constraintEnd_toEndOf="@+id/textView"
app:layout_constraintStart_toStartOf="@+id/textView3"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/fatherTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBaseline_toBaselineOf="@+id/textView2"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="53dp"
android:layout_marginLeft="53dp"
android:layout_marginBottom="6dp"
android:text="Date of Birth:"
app:layout_constraintBottom_toBottomOf="@+id/dobTxt"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/dobTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:ems="10"
android:inputType="date"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fatherTxt" />
<TextView
android:id="@+id/textView4"
android:layout_width="63dp"
android:layout_height="34dp"
android:layout_marginStart="59dp"
android:layout_marginLeft="59dp"
android:layout_marginTop="58dp"
android:layout_marginEnd="59dp"
android:layout_marginRight="59dp"
android:text="Sex:"
app:layout_constraintEnd_toEndOf="@+id/textView2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<RadioGroup
android:id="@+id/radioSex"
android:layout_width="207dp"
android:layout_height="126dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="51dp"
app:layout_constraintBottom_toBottomOf="@+id/textView5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dobTxt"
app:layout_constraintVertical_bias="0.0">
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Male" />
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Female" />
</RadioGroup>
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="53dp"
android:layout_marginLeft="53dp"
android:layout_marginEnd="47dp"
android:layout_marginRight="47dp"
android:text="Degree:"
app:layout_constraintEnd_toStartOf="@+id/DegSpinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/DegSpinner" />
<Spinner
android:id="@+id/DegSpinner"
android:layout_width="0dp"
android:layout_height="29dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="140dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView5" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="112dp"
android:layout_marginRight="112dp"
android:layout_marginBottom="56dp"
android:onClick="SendData"
android:text="Transfer Data"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
3.ALERT DIALOGS
AIM:
ALGORITHM:
STEP 5:Make an alertdialog with three messages as yes,no and cancel,if the button was
clicked.
PROGRAM:
MainActivity.Java
package com.example.alertdialogtesting;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void ShowAlert(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Alert Dialog Example");
builder.setMessage("Are You sure, you want to continue ?");
builder.setCancelable(false);
builder.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MainActivity.this, "Selected Option: yes",
Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MainActivity.this, "Selected Option: No",
Toast.LENGTH_SHORT).show();
}
});
AlertDialog dialog = builder.create();
dialog.show();a
}
}
Activity_Main.XML
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="111dp"
android:layout_marginStart="1dp"
android:layout_marginLeft="1dp"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:onClick="ShowAlert"
android:text="ShowAlertDialog"
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>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
4.LIST VIEW
AIM:
ALGORITHM:
STEP 3:Declare and initialize the listview and adapter in main activity .
MainActivity.Java
package com.example.list;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
ListView mylist;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String androidversion[]={"Cupcake :1.5","Dount :1.6","Eclair :2.0","Froyo
:2.2","Gingerbread :2.3"};
mylist = (ListView)findViewById(R.id.outlist);
adapter=new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,androidversion);
mylist.setAdapter(adapter);
mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i,
long l) {
String value = adapter.getItem(i);
Toast.makeText(getApplicationContext(),value,Toast.LENGTH_SHORT).show();
}
});
}
Activity_Main.XML
<ListView
android:id="@+id/outlist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
5.OPTIONS MENU
AIM:
ALGORITHM:
MainActivity.Java
package com.example.option;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.main,menu);
return true;
}
public boolean OnOptionItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.about:
Toast.makeText(this,"your are
selected"+item.getTitle().toString(),Toast.LENGTH_SHORT).show();
return true;
case R.id.help:
Toast.makeText(this,"your are
selected"+item.getTitle().toString(),Toast.LENGTH_SHORT).show();
return true;
case R.id.setting:
Toast.makeText(this,"your are
selected"+item.getTitle().toString(),Toast.LENGTH_SHORT).show();
return true;
case R.id.exit:
Toast.makeText(this,"your are
selected"+item.getTitle().toString(),Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Main.XML
Main_Activity.XML
OUTPUT:
x
RESULT:
Thus the above android application was developed and verified successfully.
6.SEEK BAR
AIM:
ALGORITHM:
STEP 2:Set text view,edit text and seek bar in the xml file.
STEP 3:Declare and initialize the text view and seek bar in the main activity.
STEP 4:To initialize the pval=0 for change the seek bar value.
MainActivity.java
package com.example.seekbar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.SeekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sBar = (SeekBar)findViewById(R.id.seekBar);
t1 = (EditText)findViewById(R.id.txt1);
sBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int pval=0;
@Override
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
t1.setText(pval +"/" +sBar.getMax());
}
});
}
}
Activity_Main.XML
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="20dp"
android:text="seekBar Example"
android:textSize="30sp" />
<EditText
android:id="@+id/txt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:padding="20dp"
android:textSize="22dp"
android:layout_marginTop="20dp"
/>
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:max="100"
android:padding="20dp"
android:progress="0" />
</LinearLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
7.SHARED PREFERENCES
AIM:
To develop an android application by using Shared Preferences .
ALGORITHM:
STEP 5:Store the data from edittexts into the shared preferences,when the button1 is clicked.
STEP 6:Retrieve the data from shared preferences,when the button2 is clicked.
STEP 7:Show the data from the shared preferences,using the toast.
STEP 8:Exit from the second screen when the button3 is clicked.
MainActivity.Java
package com.example.sharedpreferenceexample;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
EditText t1,t2,t3,t4;
String Rollno = "rollkey";
String Sname = "namekey";
String Degree = "degreekey";
String Dept ="deptkey";
String Mypref = "Myprefs";
SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t1=(EditText)findViewById(R.id.rolltxt);
t2=(EditText)findViewById(R.id.nametxt);
t3=(EditText)findViewById(R.id.degreetxt);
t4=(EditText)findViewById(R.id.depttxt);
sharedPreferences = getSharedPreferences(Mypref, Context.MODE_PRIVATE);
}
editor.putString(Rollno,rollno);
editor.putString(Sname,stuname);
editor.putString(Degree,degree);
editor.putString(Dept,dept);
editor.commit();
}
}
SharedValueShow.Java
package com.example.sharedpreferenceexample;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shared_value_show);
sharedPreferences = getSharedPreferences("Myprefs", Context.MODE_PRIVATE);
}
Toast.makeText(SharedValueShow.this,allval,Toast.LENGTH_SHORT).show();
}
Activity_Main.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_horizontal"
android:text="SharedPreferenceExample"
android:textSize="30dp" />
<EditText
android:id="@+id/rolltxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="center_horizontal|left"
android:hint="Roll No"
android:inputType="textPersonName"
android:padding="20dp"
android:textSize="20dp" />
<EditText
android:id="@+id/nametxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="center_horizontal|left"
android:hint="Student Name"
android:inputType="textPersonName"
android:padding="20dp"
android:textSize="20dp" />
<EditText
android:id="@+id/degreetxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="center_horizontal|left"
android:hint="Degree"
android:inputType="textPersonName"
android:padding="20dp"
android:textSize="20dp" />
<EditText
android:id="@+id/depttxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="center_horizontal|left"
android:hint="Department"
android:inputType="textPersonName"
android:padding="20dp"
android:textSize="20dp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="Save To Shared Preference"
android:textSize="15dp"
android:layout_marginTop="20dp"
android:onClick="SharedButton"
/>
</LinearLayout>
Activity_Shared_Value_Show.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center_vertical"
android:orientation="vertical"
tools:context=".SharedValueShow">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Show Preference"
android:onClick="ShowValue"
/>
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Clear Value"
android:onClick="ClearValue"
/>
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Exit"
android:onClick="Exit"
/>
</LinearLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
8.STATUS BAR NOTIFICATIONS
AIM:
To develop an android application by using Status Bar Notifications.
ALGORITHM:
MainActivity.Java
package com.example.notificationdemo;
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
Button b1;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button)findViewById(R.id.button);
b1.setOnClickListener(new View.OnClickListener() {
@Override
addNotification();
});
}
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.abc)
.setContentTitle("Notifications Example")
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
// Add as notification
manager.notify(0, builder.build());
ActivityMain.XML
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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notification Example"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff87ff09"
android:textSize="30dp"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/abc"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notification"
android:id="@+id/button"
android:layout_marginTop="62dp"
android:layout_below="@+id/imageButton"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
Manifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notificationdemo" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.notificationdemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
</intent-filter>
</activity>
<activity android:name=".NotificationView"
android:label="Details of notification"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
</application>
</manifest>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
9.TAB WIDGETS TALKING CLOCK
AIM:
ALGORITHM:
STEP 3:Decalre and initialize the button and textview in main activity
MainActivity.Java
package com.example.sairamkrishna.myapplication;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews;
import android.widget.Toast;
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse(url));
views.setOnClickPendingIntent(R.id.button, pending);
appWidgetManager.updateAppWidget(currentWidgetId,views);
}
}
ActivityMain.XML
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:transitionGroup="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tutorials point"
android:id="@+id/textView"
android:layout_centerHorizontal="true"
android:textColor="#ff3412ff"
android:textSize="35dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Widget"
android:id="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:layout_below="@+id/textView" />
</RelativeLayout>
Manifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sairamkrishna.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name=".MainActivity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"></action>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/mywidget"></meta-data>
</receiver>
</application>
</manifest>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
10.TWEEN ANIMATION
AIM:
ALGORITHM:
STEP 3:Decalre and initailize the button and image view in main activity
STEP 5: The animation was running when the button was clicked
package com.tween.pack;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;
ImageView image;
}
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.menu_file,menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
Animation animation;
Toast.makeText(getApplicationContext(),"Clicked:"+item,Toast.LENGTH_LONG).show();
switch(item.getItemId())
{
case R.id.rotate:
animation= AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.rotate);
image.startAnimation(animation);
return true;
case R.id.fade:
animation= AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.fade);
image.startAnimation(animation);
return true;
case R.id.zoom:
animation= AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.zoom);
image.startAnimation(animation);
return true;
case R.id.move:
animation= AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.move);
image.startAnimation(animation);
return true;
}
return false;
}
res/layout/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:gravity="center_horizontal|center_vertical"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
res/menu/menu_file.xml
</menu>
res/anim/fade.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000"/>
</set>
res/anim/move.xml
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="-75%p"
android:toXDelta="75%p"
android:duration="2000" />
</set>
res/anim/rotate.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000">
</rotate>
<rotate
android:startOffset="1500"
android:fromDegrees="360"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000">
</rotate>
</set>
res/anim/zoom.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="0.5"
android:toXScale="2.5"
android:fromYScale="0.5"
android:toYScale="2.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000" >
</scale>
</set>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
11.GRID VIEW
AIM:
ALGORITHM:
STEP 3:Declare and initialize the gridview and adapter in the main activity
src/com.gridview.pack.GridViewActivity.java
package com.gridview.pack;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.Toast;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;
GridView gv;
static final String[] number = new
String[]{"Mango","Apple","Pine","Lemon","Graphes","Coconut","Banana","Orange"};
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gv=(GridView)findViewById(R.id.gridView1);
ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,number);
gv.setAdapter(adapter);
gv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent ,View view,int position,long id)
{
Toast.makeText(getApplication(),((TextView)view).getText(),Toast.LENGTH_SHORT)
.show();
}
});
}
}
res/layout/main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3" >
</GridView>
</LinearLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
12.INTERNAL STORAGE FILES
AIM:
ALGORITHM:
STEP 2:To set button save and load in the xml file
STEP7:To used for inputstream and outputstream in internal storage files in mainactivity
MainActivity.Java
package com.example.sairamkrishna.myapplication;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Button b1,b2;
TextView tv;
EditText ed1;
String data;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.button);
b2=(Button)findViewById(R.id.button2);
ed1=(EditText)findViewById(R.id.editText);
tv=(TextView)findViewById(R.id.textView2);
b1.setOnClickListener(new View.OnClickListener() {
@Override
data=ed1.getText().toString();
try {
fOut.write(data.getBytes());
fOut.close();
Toast.makeText(getBaseContext(),"file saved",Toast.LENGTH_SHORT).show();
catch (Exception e) {
e.printStackTrace();
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
try {
int c;
String temp="";
tv.setText(temp);
Toast.makeText(getBaseContext(),"file read",Toast.LENGTH_SHORT).show();
catch(Exception e){
});
ActivityMain.XML
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
android:layout_height="wrap_content"
android:id="@+id/textview"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tutorials point"
android:id="@+id/textView"
android:layout_below="@+id/textview"
android:layout_centerHorizontal="true"
android:textColor="#ff7aff24"
android:textSize="35dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:hint="Enter Text"
android:focusable="true"
android:textColorHighlight="#ff7eff15"
android:textColorHint="#ffff25e6"
android:layout_below="@+id/imageView"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"
android:layout_marginTop="42dp"
android:layout_alignLeft="@+id/imageView"
android:layout_alignStart="@+id/imageView" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/abc"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="load"
android:id="@+id/button2"
android:layout_alignTop="@+id/button"
android:layout_alignRight="@+id/editText"
android:layout_alignEnd="@+id/editText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Read"
android:id="@+id/textView2"
android:layout_below="@+id/editText"
android:layout_toLeftOf="@+id/button2"
android:layout_toStartOf="@+id/button2"
android:textColor="#ff5bff1f"
android:textSize="25dp" />
</RelativeLayout>
Manifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sairamkrishna.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
13.SQLITE-DATABASE
AIM:
ALGORITHM:
STEP 2:To set text view and edit text in the xml file
package com.sql.pack;
import android.app.Activity;
import android.os.Bundle;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
sqlDb=openOrCreateDatabase("STDB",getApplicationContext().MODE_PRIVATE,null);
sqlDb.execSQL("CREATE TABLE IF NOT EXISTS STDINFORMATION(REGNO
VARCHAR(12),NAME VARCHAR(20),DEPT VARCHAR(20))");
btnAdd.setOnClickListener(new View.OnClickListener()
{
if(stRegNO.equals("")||stName.equals("")||stDept.equals(""))
{
Toast.makeText(getApplicationContext(), "Fields cannot be
empty",Toast.LENGTH_SHORT).show();
}
else
{
sqlDb.execSQL("INSERT INTO STDINFORMATION(REGNO,NAME,DEPT)
VALUES('"+stRegNO+"','"+stName+"','"+stDept+"')");
Toast.makeText(getApplicationContext(),"Value Inserted!!",Toast.LENGTH_SHORT)
.show();
txtRegNo.setText("");
txtName.setText("");
txtDept.setText("");
}
});
btnDelete.setOnClickListener(new View.OnClickListener()
{
searchStudent = txtRegNo.getText().toString().trim();
if(searchStudent.equals(""))
{
Toast.makeText(getApplicationContext(), "Fields cannot be
empty!!",Toast.LENGTH_SHORT).show();
return;
}
if(cDel.moveToFirst())
Else
{
Toast.makeText(getApplicationContext(), "Data not found!!",Toast.LENGTH_SHORT)
.show();
}
}
});
btnSearch.setOnClickListener(new View.OnClickListener()
{
if(searchStudent.equals(""))
{
Toast.makeText(getApplicationContext(), "Fields cannot be
empty!!",Toast.LENGTH_SHORT).show();
return;
}
if(c.moveToFirst())
{
txtRegNo.setText(c.getString(0));
txtName.setText(c.getString(1));
txtDept.setText(c.getString(2));
}
else
{
Toast.makeText(getApplicationContext(), "Data not
found!!",Toast.LENGTH_SHORT).show();
}
}
});
btnClear.setOnClickListener(new View.OnClickListener()
{
txtRegNo.setText("");
txtName.setText("");
txtDept.setText("");
}
});
}
}
res/layout/main.xml
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="42dp"
android:text="RegNo"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="44dp"
android:text="Dept"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button2"
android:layout_alignTop="@+id/textView3"
android:ems="10" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView2"
android:layout_below="@+id/editText3"
android:layout_marginTop="53dp"
android:text="ADD" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/textView2"
android:text="DELETE" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button2"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/button2"
android:text="SEARCH" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button3"
android:layout_alignParentRight="true"
android:text="CLEAR" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/editText3"
android:ems="10" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignLeft="@+id/editText2"
android:ems="10" />
</RelativeLayout>
</LinearLayout>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
14.GOOGLE MAP
AIM:
ALGORITHM:
MainActivity.Java
package example.com.mapexample;
import android.support.v4.app.FragmentActivity;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
}
ActivtyMain.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.com.mapexample">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
-->
<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/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
</activity>
</application>
</manifest>
OUTPUT:
RESULT:
Thus the above android application was developed and verified successfully.
15.PERMISSIONS
AIM:
ALGORITHM:
STEP 4:To Click the button then the button helps to open a warning message
STEP 5:If you click the Allow button then permission is granted
.
PROGRAM:
MainActivity.Java
package org.geeksforgeeks.requestPermission;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
storage = findViewById(R.id.storage);
camera = findViewById(R.id.camera);
storage.setOnClickListener(new View.OnClickListener() {
@Override
checkPermission(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
STORAGE_PERMISSION_CODE);
});
camera.setOnClickListener(new View.OnClickListener() {
@Override
checkPermission(Manifest.permission.CAMERA,
CAMERA_PERMISSION_CODE);
});
if (ContextCompat.checkSelfPermission(MainActivity.this, permission)
== PackageManager.PERMISSION_DENIED) {
ActivityCompat.requestPermissions(MainActivity.this,
requestCode);
else {
Toast.makeText(MainActivity.this,
.show();
@Override
super
.onRequestPermissionsResult(requestCode,
permissions,
grantResults);
if (requestCode == CAMERA_PERMISSION_CODE) {
if (grantResults.length > 0
Toast.makeText(MainActivity.this,
Toast.LENGTH_SHORT)
.show();
else {
Toast.makeText(MainActivity.this,
Toast.LENGTH_SHORT)
.show();
}
}
if (grantResults.length > 0
Toast.makeText(MainActivity.this,
Toast.LENGTH_SHORT)
.show();
else {
Toast.makeText(MainActivity.this,
Toast.LENGTH_SHORT)
.show();
MainActivity.XML
<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">
<!-- To show toolbar-->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
app:titleTextColor="@android:color/white"
android:layout_height="?android:attr/actionBarSize"/>
<Button
android:id="@+id/storage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Storage"
android:layout_marginTop="16dp"
android:padding="8dp"
android:layout_below="@id/toolbar"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Camera"
android:layout_marginTop="16dp"
android:padding="8dp"
android:layout_below="@id/storage"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Manifest.XML
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.geeksforgeeks.requestPermission">
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.CAMERA" />
<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/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action
android:name="android.intent.action.MAIN" /
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Output:
RESULT:
Thus the above android application was developed and verified successfully.