You are on page 1of 66

CHAPTER 1

INTRODUCTION

1
1.1 MOTIVATION
As we know that now a days most of communication is mobile based commu-
nication so we want to do an application in mobile platform. By observing all the mo-
bile operating systems we found that Android is the most used operating system. So
we selected this project to have some knowledge on the latest platform (ANDROID),
current technologies which are going on now and want to design a Good application.

1.2 PROBLEM DEFINITION

One of the fastest growing industries now a day is mobile industry. There are
many competitors in this area who are doing research and development on new plat-
forms & user experience. One such technology is Android from Google which is sup-
ported for many manufactured phones. One of the fastest growing industries now a day
is mobile industry. There are many competitors in this area who are doing research and
development on new platforms & user experience. One such technology is Android
from Google which is supported for many manufactured phones. These phones are
described as next Generation mobiles [As described by Google].
The project is develop a mobile application which provides contact information about
a student and their parents .This application will also be used as base for further mod-
ification in which it would be used to manage the complete contact details of each and
every member of the college .

1.3 OBJECTIVE OF THE PROJECT


The main objective of the project is to help the faculty by providing contact de-
tails of the students and also their parents in-order to improve the communication be-
tween them.

1.4 LIMITATIONS OF THE PROJECT


The limitation related with this project is that this application charges money in-
order to make a call or to send a message according to our network provider .
2
CHAPTER 2
LITERATURE SURVEY

3
2.1 LITERATURE SURVEY
Android is a software stack for mobile devices that includes an operating system, mid-
dleware and key applications. The android SDK provides the tools and APIs necessary
to begin developing applications on the Android platform using the Java programming
language.
The Android SDK includes a comprehensive set of development tools. These include
a debugger, libraries, a handset emulator (based on QEMU), documentation, sample
code, and tutorials. Currently supported development platforms include x86-architec-
ture computers running Linux (any modern desktop Linux distribution), Mac OS X
10.4.8 or later, Windows XP or Vista. The officially supported integrated development
environment (IDE) is Eclipse (3.2 or later) using the Android Development Tools
(ADT) Plug in, though developers may use any text editor to edit Java and XML files
then use command line tools to create, build and debug Android applications.

By observing all the mobile operating systems we found that Android is the most used
operating system. So we selected this project to have some knowledge on the latest
platform (ANDROID), current technologies which are going on now and want to de-
sign a Good application.

World is contracting with the growth of mobile phone technology. As the number of
users is increasing day by day, facilities are also increasing. Starting with simple reg-
ular handsets which were used just for making phone calls, mobiles have changed our
lives and have become part of it. Now they are not used just for making calls but they
have innumerable uses and can be used as a Camera , Music player, Tablet PC, T.V. ,
Web browser etc

Android comes with an Android market which is an online software store. It was de-
veloped by Google. It allows Android users to select, and download applications de-
veloped by third party developers and use them. There are around 2.0 lack+ games,
application and widgets available on the market for users.
4
Android applications are written in java programming language. Android is available
as open source for developers to develop applications which can be further used for
selling in android market. There are around 200000 applications developed for android
with over 3 billion+ downloads. Android relies on Linux version 2.6 for core system
services such as security, memory management, process management, network stack,
and driver model. For software development, Android provides Android SDK (Soft-
ware development kit)

APPLICATIONS :
These are the basics of Android applications:
Android applications are composed of one or more application components (ac-
tivities, services, content providers, and broadcast receivers)
Each component performs a different role in the overall application behaviour,
and each one can be activated individually (even by other applications)
The manifest file must declare all components in the application and should also
declare all application requirements, such as the minimum version of Android required
and any hardware configurations required
Non-code application resources (images, strings, layout files, etc.) should include
alternatives for different device configurations (such as different strings for different
languages)

2.2 REVIEW OF RELATED LITERATURE FROMRELATED RE-SEARCH


PAPER
Creating and Using Databases for Android Applications
Android is an open source software assemble of an operating system, middleware and
key applications for mobile devices introduced by Google capable of running multiple
application programs. It is a complete operating environment based upon the Linux
V2.6 kernel. Initially, the deployment target for Android was the mobile-phone arena
such as smart phones and low-cost flip-phone devices.
5
Android platform is produced to make new and innovative mobile application program
for the developers to make full use of all functions connected to handset internet. As a
complete mobile platform, Android provides universal set of powerful Operation Sys-
tem, Comprehensive Library Set, abundant Multimedia User Interface and Phone Ap-
plication. The data-storage burden is eased because the Android platform includes the
popular open source SQLite database. SQLite is a software library that implements a
SQL engine. It has been used with great success as on-disk file format: allows the de-
veloper to handle data in a simple way, but also have the use of database features (such
as undo, redo, etc.). In embedded device environment, in which there is low-concur-
rency and there are little or medium size datasets, SQLite is the right choice.
In this paper, we discuss the overview of the android platform, it architecture and the
android applications. The data storage for Android featuring the SQLite database was
also discussed.

2.3 OVERVIEW OF THE ANDROID PLATFORM


Android is a set of software for mobile devices including Operation System, Middle-
ware and Core Application, and a new Mobile Platform of Google. It is a complete
mobile platform based on LINUX 2.6 Kernel that provides universal set of powerful
Operation System, Comprehensive Library Set, abundant Multimedia User Interface
and Phone Application. Android platform is produced to make new and innovative
mobile application program for the developers to make full use of all functions con-
nected to handset internet. The Android platform was developed by Google and later
the Open Handset Alliance (OHA).
The Open Handset AllianceTM is a group of mobile and technology companies who
come together to accelerate innovation in mobile and offer consumers a richer, less
expensive, and better mobile experience for consumers.
The Android SDK provides the tools and APIs necessary to begin developing applica-
tions on the Android platform using the Java programming language.
Android is a multi-process system in which each application (and parts of the system)
runs its own process. Security between applications and the system is enforced at the
6
process level through standard Linux facilities such as user and group IDs that are as-
signed to applications.
Additional finer-grained security features are provided through a permission mech-
anism that enforces restrictions on the specific operations that a particular process can
perform, and per-URI permissions for granting ad-hoc access to specific pieces of data.

2.4 ANDROID ARCHITECTURE


Linux Kernel. Android relies on Linux version 2.6 for core system services such as
security, memory management, process management, network stack, and driver model.
The kernel also acts as an abstraction layer between the hardware and the rest of the
software stack
Libraries. Android includes a set of C/C++ libraries used by various components of the
Android system. These capabilities are exposed to developers through the Android ap-
plication framework.
SYSTEM C LIBRARY - a BSD-derived implementation of the standard C system
library(libc), tuned for embedded Linux-based devices

MEDIA LIBRARIES - based on PacketVideo's OpenCORE; the libraries support


playback and recording of many popular audio and video formats, as well as
static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
SURFACE MANAGER - manages access to the display subsystem and seamlessly
computes 2D and 3D graphic layers from multiple applications

LIBWEB CORE - a modern web browser engine which powers both the android
browser and embeddable view

7
SGL- the underlying 2D graphics engine

3D LIBRARIES - an implementation based on OpenGL ES 1.0 APIs; the libraries use


either hardware 3D acceleration (where available) or the included, highly opti-
mized 3D software rasterizer.

SQLITE - a powerful and lightweight relational database engine available to all


applications Android Runtime.

DALVIK VIRTUAL MACHINE:Dalvik has been written so that a device can run
multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executa-
ble (.dex) format which is optimized for minimal memory footprint.

8
APPLICATION FRAMEWORK: By providing an open development platform, An-
droid offers developers the ability to build extremely rich and innovative appli-
cations.

An Android application consists of one or more of the following classifications :


ACTIVITIES : An application that has a visible UI is implemented with an activ-
ity.When a user selects an application from the home screen or application
launcher, an activity is started.

9
SERVICES : A service should be used for any application that needs to persist for a
long time, such as a network monitor or update-checking application.

CONTANT PROVIDERS : You can think of content providers as a database server.


A content provider's job is to manage access to persisted data, such as a SQLite
database. If your application is very simple, you might not necessarily create a
content provider. If you're building a larger application, or one that makes data
available to multiple activities or applications, a content provider is the means
of accessing your data.

BROADCAST RECIEVERS : An Android application may be launched to process


a element of data or respond to an event, such as the receipt of a text message.
An Android application along with a file called AndroidManifest.xml is de-
ployed to a device. The AndroidManifest.xml contains the necessary configura-
tion information properly installed to the device. It includes the required class
names and types of events the application is able to process, and the required
permissions the application needs to run. For example, if an application requires
access to the network to download a file, for example this permission must
be explicitly stated in the manifest file. Many applications may have this specific
permission enabled. Such declarative security helps reduce the likelihood that a
rogue application can cause damage on your device.

The lifeline for every Android application is its database support. A database
system is needed to store structured data, unless the application deals only with
simple data. Android uses the SQLite database system, which is an open-source,
stand-alone SQL database, widely used by many popular applications. SQLite
is a lightweight transactional database engine that occupies a small amount of
disk storage and memory, thus, it is a perfect choice for creating databases on
many mobile operating systems such as Android and iOS.

10
The database that is created for an application is only accessible to itself; other appli-
cations will not be able to access it. Once created, the SQLite database is stored in the
/data/data/<package_name>/databases folder of an Android device.

2.5 WHAT IS SQLITE ?


SQLite is an Open Source Database which is embedded into Android. SQLite supports
standard relational database features like SQL syntax, transactions and prepared state-
ments. In addition it requires only little memory at runtime (approx. 250 KByte).
SQLite is a software library that implements a self-contained, serverless, zero- config-
uration, transactional SQL database engine. SQLite is the most widely deployed SQL
database engine in the world [3, 7].
SQLite supports the data types TEXT (similar to String in Java), INTEGER (similar to
long in Java) and REAL (similar to double in Java). All other types must be converted
into one of these fields before saving them in the database. SQLite itself does not val-
idate if the types written to the columns are actually of the defined type, e.g. writing an
integer into a string column and vice versa.
SQLite is available on every Android device. Using an SQLite database in Android
does not require any database setup or administration. The SQL statements for creating
and updating the database must only be defined and the database is automatically man-
aged for users by the Android platform.

2.6 USING THE SQLITE DATABASE


Android provides full support for SQLite databases. Any databases that is created will
be accessible by name to any class in the application, but not outside the application.

11
The recommended method to create a new SQLite database is to create a subclass of
SQLiteOpenHelper and override the onCreate() method, in which and SQLite com-
mand is executed to create tables in the database. An example is shown in Figure 4.

You can then get an instance of the SQLiteOpenHelper implementation using the con-
structor that is being defined. To write to and read from the database, the getWrita-
bleDatabase() and getReadableDatabase() are called, respectively. Both returns an
SQLiteDatabase object that represents the database and provides methods for SQLite
operations.
SQLite queries can be executed using the SQLiteDatabase query() methods, which ac-
cept various query parameters, such as the table to query, the projection, selection,
columns, grouping, and others. For complex queries, such as those that require column
aliases, the SQLiteQueryBuilder is used, which provides several convenient methods
for building queries.
Every SQLite query will return a Cursor that points to all the rows found by the query.
The Cursor is always the mechanism with which can navigate results from a database
query and read rows and columns [7].

12
2.7 OTHER DATABASES :
Cellica Database for Android allows viewing and updating the database contents on an
Android device. It allows to sync with Microsoft Access, Microsoft Excel, and any
ODBC Compliant database like Oracle, SQL Server etc. The software package consists
of two software: the Cellica Database Desktop (Server) that runs on Microsoft Win-
dows, and Android device Cellica Database (Client) that run on the Android device.
The Desktop side software is used to create the database profiles (make the list of da-
tabase) for Android phone/ Tablet and data will be synchronizing with Android
phone/Tablet depending on the sync settings on phone/Tablet [8].
Cellica Database on Android phone/Tablet features include synchronized data wire-
lessly with Android phone/Tablet, view and update data, apply SQL Select queries,
filters, sort the fields and synchronize data accordingly, supported password protection,
supported forms, custom database creation, and so on.
Memento is a personal database that allows Android users to store all personal data in
one place. Entries can be synchronized with Google Docs. For example, Memento han-
dles collections, purchases, inventory, recipes, and tasks. Main features include storing
entries with custom fields, sorting, grouping and filtering entries by any fields, pass-
word protection, synchronization with Google docs, sending entries via SMS, e- mail
and other available devices, barcode scanning, backing up entries and restoring data,
and so on.

13
CHAPTER 3
ANALYSIS

14
3.1 INTRODUCTION
System analysis refers to analysing the projects hardware and software require-
ments. It is often done for diagnostic or troubleshooting purposes. Running a system
analysis can also be helpful when determining if the project meets all the desired re-
quirements.

3.2 EXISTING SYSTEM

Presently we have to options available :

1. Generally all the communication details of the students are stored in a database and
whenever they or their parents need to be contacted the information needs to be
searched in the database and retrieved. Then proper means of communication has to
be adopted.

2. We have a phone directory but opening that and storing names and contact details
of individual students is a long process. For each and every student their contact de-
tails needs to be stored and a separate contact of their parent also needs to be created.

LIMITATIONS OF EXIXTING SYSTEM

Both the methods are time consuming and there is also a chance of loss of data.Also
proper maintenance of the information is needed and proper storage and retrieval
techniques needs to be applied in order to maintain the consistency of database.

3.3 PROPOSED SYSTEM

The aim of our mini project is to develop a mobile application which contains the
contact details of the students and also their parents in an embedded database. This
would help the faculties to contact the student or their parents via a phone call , mes-
sage or an e-mail as and when its required .

15
ADVANTAGES OF PROPOSED SYSTEM

1.There is no chance of loss of data

2.It doesn't require any maintenance to manage all the contact information

3.Very easy to use and communicate whenever required

3.4 HARDWARE AND SOFTWARE REQIREMENT SPECIFICA


TION
3.4.1 HARDWARE REQIREMENTS :
PROCESSOR : Core i3 and above

RAM : 4GB RAM

MONITOR : 15 COLOR

HARD DISK : 80 GB

3.4.2 SOFTWARE REQUIREMENTS:

Front End : Java , Xml

Back End : SQLite

Operating System : Windows Family, MAC OS, Linux etc..

IDE : Android Studio AVD: Android Emulator or Genymotion

16
CHAPTER 4
DESIGN

17
4.1 DESIGN DETAILS
The Unified Modeling Language (UML) offers a way to visualize a system's archi-
tectural blueprints in a diagram including elements such as:

Individual components of the system

And how Any activities (jobs)

they can interact with other software components.


How the system will run

How entities interact with others (components and interfaces)

External user Interface.

Although originally intended solely for object-oriented design documentation, the


Unified Modelling Language (UML) has been extended to cover a larger set of de-
sign documentation (as listed above), and been found useful in many contexts.

4.1.1 DATA FLOW DIAGRAM :

A data flow diagram (DFD) is a graphical representation of the flow of data


through an information system.

It differs from the flowchart as it shows the data flow instead of the control
flow of the program.

A data flow diagram can also be used for the visualisation of data processing.

The DFD is designed to show how a system is divided into smaller portions
and to highlight the flow of data between those parts.

18
FIGURE : DATA FLOW DIAGRAM

19
USE CASE DIAGRAM
A use case diagram at its simplest is a representation of a user's interaction
with the system and depicting the specifications of use-case. A use case diagram can
portray the different types of users of a system and the various ways that they interact
with the system.

A use case diagram can also be defined as users interaction the system that shows the
relationship between the user and the different use cases in which the user is in-
volved. A use case diagram can identify the different types of users of a system and
the different use cases and will often be accompanied by other types of diagrams as
well.
IDENTIFYING ACTORS:
Actor is a role of an object
Actor:User

IDENTIFYING USE CASES:


Use-cases represents set of scenarios
1.Select
2.Students List
3.Search Student
4.Make Phone Call
5.Send Message
6.Send E-mail

20
FIGURE: USECASE DIAGRAM

21
CLASS DIAGRAM
In software engineering, a class diagram in the Unified Modeling Language (UML)
is a type of static structure diagram that describes the structure of a system by showing
the system's classes, their attributes, operations (or methods), and the relationships
among the classes.

IDENTIFYING CLASES :

Class can be defined as a collection of objects that share common properties and rela-
tionships.

Class1: User

Class2: Student List

Class3: Contact Information

Class4: Communication

22
FIG-
URE : CLASS
DIA-
GRAM

OBJECT DIAGRAM
Object diagrams reflect class diagrams in terms of real time aspects.Addresses the data
structures and provide snapshots of instances of elements internal to a class diagram.

IDENTIFYING OBJECTS:

1. User

2. Student List

3. Contact Information

FIGURE : OBJECT DIAGRAM

23
U:Us L:Lo

H:ho

24
COMPONENT DIAGRAM
The component diagram is used to address implementation view of the system that
is to be modelled.

IDENTIFYING OBJECTS :

Components bind several classes, interfaces and collaborations by physical repre-


sentation.

1. Intel XDK

2. Notepad ++

3. Operating system

FIGURE : COMPONENT DIAGRAM

Notepad
Intel

Operatingsystem

25
DEPLOYMENT DIAGRAM
Deployment diagrams reflect static deployment view of the system.The nodes
which form the major entity of the deployment diagrams take in the components
corresponding to the component diagrams before finalizing the static framework of
the system.

IDENTIFYING NODES:

1. Processor

2. Android phone

FIGURE : DEPLOYMENT DIAGRAM

26
CHAPTER 5
IMPLEMENTATION

27
5.1 MODULES
In this we have 4 modules:

1. GUI
2. Sending message to student or parent
3. Calling a parent or student message from database
4. Sending e-mails to the student

5.2 MODULE DESCRIPTION

GUI
It has got a good graphical user interface. This GUI can be used to send message or e-
mails and make phone calls from the application easily.

SENDING MESSAGE TO STUDENT OR PARENT


After searching for a particular student message can be easily sent to either student or
parent via a normal message or other applications like WhatsApp , Hike etc.

CALLING A PARENT OR STUDENT


Calls can be made both to the student or their parent very easily with a feature also of
internet calling.

SENDING E-MAILS
Mails can be sent easily with the support of inbuilt mailing apps.

28
5.3 TECHNOLOGIES USED

JAVA
Java is a set of computer software and specifications developed by Sun Microsystems,
which was later acquired by the Oracle Corporation, that provides a system for devel-
oping application software and deploying it in a cross-platform computing environ-
ment. Java is used in a wide variety of computing platforms from embedded devices
and mobile phones to enterprise servers and supercomputers. While they are less com-
mon than standalone Java applications, Java applets run in secure, sandboxed environ-
ments to provide many features of native applications and can be embedded in HTML
pages. Writing in the Java programming language is the primary way to produce code
that will be deployed as byte code in a Java Virtual Machine (JVM); byte code com-
pilers are also available for other languages, including Ada, JavaScript, Python, and
Ruby. In addition, several languages have been designed to run natively on the JVM,
including Scala, Clojure and Apache Groovy. Java syntax borrows heavily from C and
C++, but object-oriented features are modeled after Smalltalk and Objective-C. Java
eschews certain low-level constructs such as pointers and has a very simple memory
model where every object is allocated on the heap and all variables of object types are
references. Memory management is handled through integrated automatic garbage col-
lection performed by the JVM.

ANDROID STUDIO

Android Studio is the official integrated development environment (IDE) for An-
droid platform development.It was announced on May 16, 2013 at the Google I/O
conference. Android Studio is freely available under the Apache License 2.0.

Android Studio was in early access preview stage starting from version 0.1 in May
2013, then entered beta stage starting from version 0.8 which was released in June
2014.The first stable build was released in December 2014, starting from version 1.0.

29
Based on JetBrains' IntelliJ IDEA software, Android Studio is designed specifically
for Android development. It is available for download on Windows, Mac OS X and
Linux,and replaced Eclipse Android Development Tools (ADT) as Google's primary
IDE for native Android application development.

SQLITE DATABASE

SQLite is an in-process library that implements a self-contained, serverless, zero-con-


figuration, transactional SQL database engine. The code for SQLite is in the public
domain and is thus free for use for any purpose, commercial or private. SQLite is the
most widely deployed database in the world with more applications than we can count,
including several high-profile projects.

SQLite is an embedded SQL database engine. Unlike most other SQL databases,
SQLite does not have a separate server process. SQLite reads and writes directly to
ordinary disk files. A complete SQL database with multiple tables, indices, triggers,
and views, is contained in a single disk file. The database file format is cross-platform
- you can freely copy a database between 32-bit and 64-bit systems or between big-
endian and little-endian architectures. These features make SQLite a popular choice
as an Application File Format. Think of SQLite not as a replacement for Oracle but as
a replacement for fopen().

SQLite is a compact library. With all features enabled, the library size can be less than
500KiB, depending on the target platform and compiler optimization settings. (64-bit
code is larger. And some compiler optimizations such as aggressive function inlining
and loop unrolling can cause the object code to be much larger.) If optional features
are omitted, the size of the SQLite library can be reduced below 300KiB. SQLite can
also be made to run in minimal stack space (4KiB) and very little heap (100KiB),
making SQLite a popular database engine choice on memory constrained gadgets such
as cellphones, PDAs, and MP3 players. There is a tradeoff between memory usage
and speed. SQLite generally runs faster the more memory you give it. Nevertheless,
performance is usually quite good even in low-memory environments.
30
5.4 SAMPLE CODE

MAINACTIVITY.JAVA
package com.saurabh.studentprofiles;
import android.annotation.TargetApi;
import android.app.ListActivity;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.SearchView;
import java.util.List;
public class MainActivity extends ListActivity {
public List<Student> students;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new LoadStudentsTask().execute();
}
private class LoadStudentsTask extends AsyncTask<String, Void, Cursor> {
31
@Override
protected Cursor doInBackground(String... args) {
Uri uri = StudentProvider.CONTENT_URI;
String[] projection = { StudentDatabase.COLUMN_ID, StudentDatabase.COL-
UMN_FIRSTNAME, StudentDatabase.COLUMN_LASTNAME, StudentData-
base.COLUMN_ROLL, StudentDatabase.COLUMN_DEPARTMENT,
StudentDatabase.COLUMN_FNAME, StudentDatabase.COLUMN_PAR-
ENT_PHONE, StudentDatabase.COLUMN_MOBILE_PHONE, StudentData-
base.COLUMN_EMAIL, StudentDatabase.COLUMN_PICTURE };
String selection = null;
String[] selectionArgs = null;
String sortOrder = StudentDatabase.COLUMN_ROLL + " COLLATE LOCALIZED
ASC";
Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs,
sortOrder);
return cursor;
}
@Override
protected void onPostExecute(Cursor cursor) {
String[] dataColumns = {
StudentDatabase.COLUMN_FIRSTNAME,
StudentDatabase.COLUMN_ROLL,
StudentDatabase.COLUMN_DEPARTMENT,
StudentDatabase.COLUMN_FNAME,
StudentDatabase.COLUMN_PARENT_PHONE,
StudentDatabase.COLUMN_MOBILE_PHONE,
StudentDatabase.COLUMN_EMAIL,
StudentDatabase.COLUMN_PICTURE
};
int[] viewIDs = {
32
R.id.list_item_name,
R.id.list_item_title,
R.id.list_item_department,
R.id.list_item_city,
R.id.list_item_office_phone,
R.id.list_item_mobile_phone,
R.id.list_item_email,
R.id.list_item_picture
};
SimpleCursorAdapter records = new SimpleCursorAdapter(getBaseContext(), R.lay-
out.list_item, cursor, dataColumns, viewIDs, 0);
setListAdapter(records);
}
}

@Override
protected void onListItemClick(ListView l, View view, int position, long id) {
Uri details = Uri.withAppendedPath(StudentProvider.CONTENT_URI, "" + id);
Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details);
startActivity(detailsIntent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchManager searchManager = (SearchManager) getSystem-
Service(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView)
menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(get-
ComponentName()));
33
searchView.setIconifiedByDefault(false);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_search:
onSearchRequested();
return true;
default:
return false;
}
}

}
DETAILACTIVITY.JAVA
package com.saurabh.studentprofiles;
import java.io.IOException;
import java.io.InputStream;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
34
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
public class DetailActivity extends Activity implements OnClickListener {
public TextView mName;
public TextView rollno;
public TextView mDepartment;
public TextView fname;
private TextView mParentPhone;
private TextView mMobilePhone;
private TextView mSms;
private TextView mEmail;
private TextView psms;
private ImageView mPicture;
private int mID;
public Uri uri;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
getActionBar().setDisplayHomeAsUpEnabled(true);
35
}
Intent intent = getIntent();
Uri launchData = intent.getData();
mID = Integer.parseInt(launchData.getLastPathSegment());
uri = ContentUris.withAppendedId(StudentProvider.CONTENT_URI, mID);
mName = (TextView) findViewById(R.id.activity_detail_name);
rollno = (TextView) findViewById(R.id.activity_detail_title);
mDepartment = (TextView) findViewById(R.id.activity_detail_department);
fname = (TextView) findViewById(R.id.activity_detail_city);
mParentPhone = (TextView) findViewById(R.id.activity_detail_office_phone);
mMobilePhone = (TextView) findViewById(R.id.activity_detail_mobile_phone);
mSms = (TextView) findViewById(R.id.activity_detail_sms);
psms=(TextView)findViewById(R.id.activity_detail_parent_sms);
mEmail = (TextView) findViewById(R.id.activity_detail_email);
mPicture = (ImageView) findViewById(R.id.activity_detail_picture);
findViewById(R.id.activity_detail_call_office_button).setOnClickListener(this);
findViewById(R.id.activity_detail_office_phone).setOnClickListener(this);
findViewById(R.id.activity_detail_call_mobile_button).setOnClickListener(this);
findViewById(R.id.activity_detail_mobile_phone).setOnClickListener(this);
findViewById(R.id.activity_detail_send_sms_button).setOnClickListener(this);
findViewById(R.id.activity_detail_sms).setOnClickListener(this);
findViewById(R.id.activity_detail_send_parent_sms_button).setOnClick-
Listener(this);findViewById(R.id.activity_detail_parent_sms).setOnClick-
Listener(this);
findViewById(R.id.activity_detail_send_email_button).setOnClickListener(this);
findViewById(R.id.activity_detail_email).setOnClickListener(this);
PhoneCallListener phoneListener = new PhoneCallListener();
TelephonyManager telephonyManager = (TelephonyManager) this.getSystem-
Service(Context.TELEPHONY_SERVICE);

36
telephonyManager.listen(phoneListener, PhoneStateListener.LIS-
TEN_CALL_STATE);
new LoadEmployeesTask().execute();
}
private class LoadEmployeesTask extends AsyncTask<String, Void, Cursor> {
@Override
protected Cursor doInBackground(String... args) {
String[] projection = { StudentDatabase.COLUMN_ID, StudentDatabase.COL-
UMN_FIRSTNAME,StudentDatabase.COLUMN_LASTNAME, StudentData-
base.COLUMN_ROLL,StudentDatabase.COLUMN_DEPARTMENT, StudentData-
base.COLUMN_FNAME,StudentDatabase.COLUMN_PARENT_PHONE, Student-
Database.COLUMN_MOBILE_PHONE,StudentDatabase.COLUMN_EMAIL, Stu-
dentDatabase.COLUMN_PICTURE };
String selection = null;
String[] selectionArgs = null;
String sortOrder = null;
Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs,
sortOrder);
return cursor;
}
@Override
protected void onPostExecute(Cursor cursor) {
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
mName.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUM
N_FIRSTNAME)));
mName.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUM
N_LASTNAME)));
rollno.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_
ROLL)));
37
mDepartment.setText(cursor.getString(cursor.getColumnIndex(StudentData-
base.COLUMN_DEPARTMENT)));
fname.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_
FNAME)));
mParentPhone.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.CO
LUMN_PARENT_PHONE)));
mMobilePhone.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.C
OLUMN_MOBILE_PHONE)));
mSms.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_
MOBILE_PHONE)));
psms.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_
PARENT_PHONE)));
mEmail.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUM
N_EMAIL)));

InputStream is;
try {
is = getAssets().open("pics/" +
cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_PICTURE)));
Bitmap bit = BitmapFactory.decodeStream(is);
mPicture.setImageBitmap(bit);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
38
inflater.inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
Intent parentActivityIntent = new Intent(this, MainActivity.class);
parentActivityIntent.addFlags(Intent.FLAG_ACTIV-
ITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(parentActivityIntent);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.activity_detail_call_office_button:
case R.id.activity_detail_office_phone:
case R.id.textView5: // clicking on textView will
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + mParentPhone.getText().toString()));
startActivity(Intent.createChooser(callIntent, "Choose an Call client :"));
break;
case R.id.activity_detail_call_mobile_button:
case R.id.activity_detail_mobile_phone:
case R.id.textView7:
Intent callIntent2 = new Intent(Intent.ACTION_CALL);
callIntent2.setData(Uri.parse("tel:" + mMobilePhone.getText().toString()));
startActivity(Intent.createChooser(callIntent2, "Choose an Call client :"));
39
break;
case R.id.activity_detail_send_sms_button:
case R.id.activity_detail_sms:
case R.id.textView9:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData(Uri.parse("smsto:" +
mMobilePhone.getText().toString()));
startActivity(Intent.createChooser(smsIntent, "Choose an
Sms client :"));
break;
case R.id.activity_detail_send_parent_sms_button:
case R.id.activity_detail_parent_sms:
case R.id.textView13:
Intent psmsIntent = new Intent(Intent.ACTION_SENDTO);
psmsIntent.setData(Uri.parse("smsto:" +
mMobilePhone.getText().toString()));
startActivity(Intent.createChooser(psmsIntent, "Choose an Sms client :)); break;
case R.id.activity_detail_send_email_button:
case R.id.activity_detail_email:
case R.id.textView11:
String to = mEmail.getText().toString();
String subject = "textSubject";
String message = "textMessage";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
break;
40
}
}
private class PhoneCallListener extends PhoneStateListener {
private boolean isPhoneCalling = false;
String LOG_TAG = LANGDON";
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
Log.i(LOG_TAG, "OFFHOOK");
isPhoneCalling = true;
}
if (TelephonyManager.CALL_STATE_IDLE == state) {
Log.i(LOG_TAG, "IDLE");
if (isPhoneCalling) {
Log.i(LOG_TAG, "restart app");
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(
getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
isPhoneCalling = false;
}
}
}
}
}
STUDENTXMLPARSER.JAVA
package com.saurabh.studentprofiles;
41
import android.content.Context;
import android.view.MenuItem;
import android.widget.Button;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

public class StudentXmlParser {


static final String STUDENTS = "students";
static final String STUDENT = "student";
static final String ID = "id";
static final String FIRSTNAME = "firstName";
static final String LASTNAME = "lastName";
static final String ROLLNO = "rollno";
static final String DEPARTMENT = "department";
static final String FNAME = "fname";
static final String PARENTPHONE = "parentPhone";
static final String MOBILEPHONE = "mobilePhone";
static final String EMAIL = "email";
static final String PICTURE = "picture";
ArrayList<Student> studentList = null;
private Student currentStudent = null;
private boolean done = false;
private String currentTag = null;
public ArrayList<Student> parse(Context context) {
XmlPullParser parser = context.getResources().getXml(R.xml.student_list);
try {
int eventType = parser.getEventType();
42
while (eventType != XmlPullParser.END_DOCUMENT && !done) {
switch (eventType) {
case XmlPullParser.START_DOCUMENT:
studentList = new ArrayList<Student>();
break;
case XmlPullParser.START_TAG:
currentTag = parser.getName();
if (currentTag.equalsIgnoreCase(STUDENT)) {
currentStudent = new Student();
} else if (currentStudent != null) {
if (currentTag.equalsIgnoreCase(ID)) {
currentStudent.setId(Integer.parseInt(parser.nextText()));
}
else if (currentTag.equalsIgnoreCase(FIRSTNAME)) {
currentStudent.setFirstName(parser.nextText());
} else if (currentTag.equalsIgnoreCase(LASTNAME)) {
currentStudent.setLastName(parser.nextText()); }
else if (currentTag.equalsIgnoreCase(ROLLNO)) {
currentStudent.setTitle(parser.nextText());
} else if (currentTag.equalsIgnoreCase(DPARTMENT)) {
currentStudent.setDepartment(parser.nextText());
} else if (currentTag.equalsIgnoreCase(FNAME)) {
currentStudent.setCity(parser.nextText());
} else if (currentTag.equalsIgnoreCase(PARENTPHONE)) {
currentStudent.setOfficePhone(parser.nextText());
} else if (currentTag.equalsIgnoreCase(MOBILEPHONE)) {
currentStudent.setMobilePhone(parser.nextText());
} else if (currentTag.equalsIgnoreCase(EMAIL)) {
currentStudent.setEmail(parser.nextText());
} else if (currentTag.equalsIgnoreCase(PICTURE)) {
43
currentStudent.setPicture(parser.nextText());
}
}
break;case XmlPullParser.END_TAG:
currentTag = parser.getName();
if (currentTag.equalsIgnoreCase(STUDENT) &&
currentStudent != null) {
studentList.add(currentStudent);
} else if (currentTag.equalsIgnoreCase(STU-
DENTS)) {
done = true;
}
break;
} eventType = parser.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return studentList;
}

STUDENTDATABASE.JAVA
package com.saurabh.studentprofiles;
44
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
public class StudentDatabase extends SQLiteOpenHelper {
private Context context;
ArrayList<Student> studentList = new ArrayList<Student>();
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "student_directory";
public static final String TABLE_STUDENTS = "students";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_FIRSTNAME = "first_name";
public static final String COLUMN_LASTNAME = "last_name";
public static final String COLUMN_ROLL = "rollno";
public static final String COLUMN_DEPARTMENT = "department";
public static final String COLUMN_FNAME = "fathername";
public static final String COLUMN_PARENT_PHONE = "parent_phone";
public static final String COLUMN_MOBILE_PHONE = "mobile_phone";
public static final String COLUMN_EMAIL = "email";
public static final String COLUMN_PICTURE = "picture";

private static final String CREATE_TABLE_STUDENTS = "CREATE TA-


BLE " + TABLE_STUDENTS + " ("
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,
" + COLUMN_FIRSTNAME + " TEXT NOT NULL, "
+ COLUMN_LASTNAME + " TEXT NOT NULL, "
+ COLUMN_ROLL + " TEXT NOT NULL, "
+ COLUMN_DEPARTMENT + " TEXT NOT NULL, "
+ COLUMN_FNAME + " TEXT NOT NULL, "
45
+ COLUMN_PARENT_PHONE + " TEXT NOT NULL, "
+ COLUMN_MOBILE_PHONE + " TEXT NOT NULL, "
+ COLUMN_EMAIL + " TEXT NOT NULL, "
+ COLUMN_PICTURE + " TEXT NOT NULL);";
public StudentDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context; // DO I NEED THIS???
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_STUDENTS);
seedData(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_STUDENTS);
onCreate(db);
}
private void seedData(SQLiteDatabase db) {
StudentXmlParser parser = new StudentXmlParser();
studentList = parser.parse(context);
for (Student student : studentList) {
db.execSQL("INSERT INTO students ("
+ COLUMN_FIRSTNAME + ", "
+ COLUMN_LASTNAME + ", "
+ COLUMN_ROLL + ", "
+ COLUMN_DEPARTMENT + ", "
+ COLUMN_FNAME + ", "
+ COLUMN_PARENT_PHONE + ", "
+ COLUMN_MOBILE_PHONE + ", "
46
+ COLUMN_EMAIL + ", "
+ COLUMN_PICTURE + ")"
+ " values (\""
+ String.valueOf(student._firstName)
+ "\", \""
+ String.valueOf(student._lastName)
+ "\", \""
+ String.valueOf(student._rollno)
+ "\", \""
+ String.valueOf(student._department)
+ "\", \""
+ String.valueOf(student._fname)
+ "\", \""
+ String.valueOf(student._parentPhone)
+ "\", \""
+ String.valueOf(student._mobilePhone)
+ "\", \""
+ String.valueOf(student._email)
+ "\", \""
+ String.valueOf(student._picture) + "\");");
}

}
}

StudentProvider.java
package com.saurabh.studentprofiles;
47
import android.app.SearchManager;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import java.util.HashMap;

public class StudentProvider extends ContentProvider {


private StudentDatabase mStudentDatabase;
private final UriMatcher mUriMatcher;

private static final String AUTHORITY = "com.saurabh.studentprofiles.StudentPro-


vider";
public static final String BASE_DATA_NAME = "students";
public static final String CONTENT_ITEM_TYPE = ContentResolver.CUR-
SOR_ITEM_BASE_TYPE + "/vnd.saurabh.search." + BASE_DATA_NAME;
public static final String CONTENT_TYPE = ContentResolver.CUR-
SOR_DIR_BASE_TYPE + "/vnd.saurabh.search." + BASE_DATA_NAME;
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHOR-
ITY + "/" + BASE_DATA_NAME);
public static final Uri SEARCH_SUGGEST_URI = Uri.parse("content://" +
AUTHORITY + "/" + BASE_DATA_NAME + "/" + SearchManager.SUG-
GEST_URI_PATH_QUERY);
private static final int STUDENTS = 1;
private static final int STUDENTS_ID = 2;
private static final int SEARCH_SUGGEST = 3;

48
private static final HashMap<String, String> SEARCH_SUGGEST_PROJEC-
TION_MAP;
static {
SEARCH_SUGGEST_PROJECTION_MAP = new HashMap<String,
String>();
SEARCH_SUGGEST_PROJECTION_MAP.put(StudentData-
base.COLUMN_ID, StudentDatabase.COLUMN_ID);
SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUG-
GEST_COLUMN_TEXT_1, StudentDatabase.COLUMN_FIRSTNAME + " AS " +
SearchManager.SUGGEST_COLUMN_TEXT_1);
SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUG-
GEST_COLUMN_TEXT_2, StudentDatabase.COLUMN_LASTNAME + " AS " +
SearchManager.SUGGEST_COLUMN_TEXT_2);
SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUG-
GEST_COLUMN_INTENT_DATA_ID, StudentDatabase.COLUMN_ID + " AS " +
SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
}
public StudentProvider() {
mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mUriMatcher.addURI(AUTHORITY, StudentDatabase.TABLE_STU-
DENTS, STUDENTS);
mUriMatcher.addURI(AUTHORITY, StudentDatabase.TABLE_STU-
DENTS + "/#", STUDENTS_ID);
mUriMatcher.addURI(AUTHORITY, SearchManager.SUG-
GEST_URI_PATH_QUERY, SEARCH_SUGGEST);
mUriMatcher.addURI(AUTHORITY, SearchManager.SUG-
GEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST);
}

@Override
49
public boolean onCreate() {
mStudentDatabase = new StudentDatabase(getContext());
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] se-
lectionArgs, String sortOrder) {

SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();


queryBuilder.setTables(StudentDatabase.TABLE_STUDENTS);
switch (mUriMatcher.match(uri)) {
case SEARCH_SUGGEST:
selectionArgs = new String[] { "%" + selectionArgs[0] + "%",
"%" + selectionArgs[0] + "%" };
queryBuilder.setProjectionMap(SEARCH_SUGGEST_PROJEC-
TION_MAP);
break;
case STUDENTS:
break;
case STUDENTS_ID:
queryBuilder.appendWhere(StudentDatabase.COLUMN_ID +
"=" + uri.getLastPathSegment());
break;
default:
throw new IllegalArgumentException("Unknown URI");
}
Cursor cursor = queryBuilder.query(mStudentDatabase.getReadable-
Database(), projection, selection, selectionArgs, null,null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
50
}
@Override
public String getType(Uri uri) {
switch (mUriMatcher.match(uri)) {
case STUDENTS:
return CONTENT_TYPE;
case STUDENTS_ID:
return CONTENT_ITEM_TYPE;
case SEARCH_SUGGEST:
return null;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] se-
lectionArgs) {
return 0;
}}

STUDENT.JAVA
package com.saurabh.studentprofiles;
51
public class Student {
Integer _stuID;
String _firstName;
String _lastName;
String _rollno;
String _department;
String _fname;
String _parentPhone;
String _mobilePhone;
String _email;
String _picture;
public Student(Integer empID, String firstName, String lastName, String title,
String department, String city, String officePhone, String mobilePhone, String email,
String picture) {
this._stuID = empID;
this._firstName = firstName;
this._lastName = lastName;
this._rollno = title;
this._department = department;
this._fname = city;
this._parentPhone = officePhone;
this._mobilePhone = mobilePhone;
this._email = email;
this._picture = picture;
}
public void setId(Integer empID) {
this._stuID = empID;
}
public void setFirstName(String firstName) {
this._firstName = firstName;
52
}
public void setLastName(String lastName) {
this._lastName = lastName;
}
public void setTitle(String title) {
this._rollno = title;
}
public void setDepartment(String department) {
this._department = department;
}
public void setCity(String city) {
this._fname = city;
}
public void setOfficePhone(String officePhone) {
this._parentPhone = officePhone;
}
public void setMobilePhone(String mobilePhone) {
this._mobilePhone = mobilePhone;
}
public void setEmail(String email) {
this._email = email;
}
public void setPicture(String picture) {
this._picture = picture;
}
public Integer getId() {
return this._stuID;
}
public String getFirstName() {
return this._firstName;
53
}
public String getLastName() {
return this._lastName;
}
public String getTitle() {
return this._rollno;
}
public String getDepartment() {
return this._department;
}
public String getCity() {
return this._fname;
}
public String getOfficePhone() {
return this._parentPhone;
}
public String getMobilePhone() {
return this._mobilePhone;
}
public String getPicture() {
return this._picture;
}
@Override
public String toString() {
return _firstName + " " + _lastName + "\n" + _rollno;
}
}

SEARCHABLEACTIVITY.JAVA
package com.saurabh.studentprofiles;
54
import android.annotation.TargetApi;
import android.app.ListActivity;
import android.app.SearchManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class SearchableActivity extends ListActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
checkIntent(intent);
}
@Override
protected void onNewIntent(Intent newIntent) {
setIntent(newIntent);
checkIntent(newIntent);
}
private void checkIntent(Intent intent) {
String query = "";
String intentAction = intent.getAction();
55
if (Intent.ACTION_SEARCH.equals(intentAction)) {
query = intent.getStringExtra(SearchManager.QUERY);
} else if (Intent.ACTION_VIEW.equals(intentAction)) {
Uri details = intent.getData();
Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details);
startActivity(detailsIntent);
}
fillList(query);
}
private void fillList(String query) {
String wildcardQuery = "%" + query + "%";
Cursor cursor = getContentResolver().query(
StudentProvider.CONTENT_URI,
null,
StudentDatabase.COLUMN_FIRSTNAME + " LIKE ? OR " + StudentData-
base.COLUMN_ROLL + " LIKE ?",
new String[] { wildcardQuery, wildcardQuery },null);
ListAdapter adapter = new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_2,
cursor,
new String[] { StudentDatabase.COLUMN_FIRSTNAME,
StudentDatabase.COLUMN_ROLL },
new int[] { android.R.id.text1, android.R.id.text2 },
0);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View view, int position, long id) {
Uri details = Uri.withAppendedPath(StudentProvider.CONTENT_URI, "" + id);
56
Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details);
startActivity(detailsIntent);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
Intent parentActivityIntent = new Intent(this, MainActivity.class);
parentActivityIntent.addFlags(Intent.FLAG_ACTIVITY_
CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(parentActivityIntent);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}}

5.5 SOME PICTURES OF


PROPOSED SYSTEM

57
SRC 1: STUDENTS DETAILS IN LIST
VIEW

SRC 2 : SEARCHING A PARTICULAR STUDENT

SRC 3: COMMUNICATION DETAILS

58
SRC 4 : MESSAGING OPTIONS

SRC 5 : E-MAIL OPTIONS

59
CHAPTER 6
TESTING

60
6.1 INTRODUCTION

The development of software systems involves of a series of production activi-


ties where opportunities for injection of human fallibilities are enormous. Errors may
begin to occur at the very inception of the process where the objectives may be erro-
neously or imperfectly specified, as well as in later design and development stages.
Because of human inability to perform and communicate with perfection, software de-
velopment is accompanied by a quality assurance activity.

In general, testing is finding out how well something works. In terms of human
beings, testing tells what level of knowledge or skill has been acquired. In computer
hardware and software development, testing is used at key checkpoints in the overall
process to determine whether objectives are being met. For example, in software de-
velopment, product objectives are sometimes tested by product user representatives.
When the design is complete, coding follows and the finished code is then tested at the
unit or module level by each programmer; at the component level by the group of pro-
grammers involved; and at the system level when all components are combined to-
gether. At early or late stages, a product or service may also be tested for usability.

6.2 TESTING TOOL

61
UNIT TESTING : Unit testing is a software development process in which the
smallest testable parts of anapplication, called units, are individually and independently
scrutinized for proper operation. Unit testing is often automated but it can also be done
manually. This testing mode is a component of Extreme Programming (XP), a prag-
matic method of software development that takes a meticulous approach to building a
product by means of continual testing and revision.

Unit testing involves only those characteristics that are vital to the performance of the
unit under test. This encourages developers to modify the source code without imme-
diate concerns about how such changes might affect the functioning of other units or
the program as a whole.

6.3 TEST CASES


The development of software systems involves of a series of production activi-
ties where opportunities for injection of human fallibilities are enormous. Errors may
begin to occur at the very inception of the process where the objectives may be erro-
neously or imperfectly specified, as well as in later design and development stages.

Test Case 1
Test case 1: Home page Priority (H, L): High

Test Objective: To check if home page is working

Test Description: All the students name are displayed or not

Requirements Verified: Yes

Test Environment: Application must be deployed in android mobile phone or emulator.

Test Setup/Pre-Conditions:

62
Actions Expected Results

The user tries to access home page Home page working

Pass: Yes Conditions pass: Yes Fail: No

Problems / Issues: NIL

Notes: Successfully Executed

Test Case 2
Test case 2:Communication Details on click Priority (H, L): High

Test Objective: Accessing contact details from database

Test Description: Request to the database

Requirements Verified: Yes

Test Environment: Application must be deployed in android mobile phone or emulator.

Test Setup/Pre-Conditions:

Actions Expected Results

User click on picture Picture maximizes

Pass: Yes Conditions pass: Yes Fail: No

Problems / Issues: NIL

Notes: Successfully Executed

63
Test Case 3
Test case 3: Application functions working Priority (H, L): High

Test Objective: To check functions of application

Test Description: All the functions working or no

Requirements Verified: Yes

Test Environment: Application must be deployed in android mobile phone or emulator.

Test Setup/Pre-Conditions:

Actions Expected Results

Pronunciation check Functions working

Pass: Yes Conditions pass: Yes Fail: No

Problems / Issues: NIL

Notes: Successfully Executed

7.CONCLUSION

This application is built in Android Studio using its SDK tools .This application can
be used by the staff to communicate with the students and their parents as and when
its required without wasting any time. All the details related to a particular student

64
are displayed and directly phone calls,messages or mails can be made from this appli-
cation to any particular individual.Thus the communication between the faculty , stu-
dents and their parents is enhanced.

8. FUTURE SCOPE
This project can be modified in future in order to maintain all the student related in-
formation of the entire college in a single application.Several other changes like in-
ternet messaging and internet calling are also possible to be added.It has all the fea-
tures to become a substitute for the most commonly used inbuilt phone directory.Ease
of use , no chance of loss of data and less maintenance cost makes it a highly desired
application for the users.Apart from the application part android widget for the appli-
cation can also be created which would provide a much faster access to a particular
individuals information instead of searching for a particular person.

65
66

You might also like