Sunteți pe pagina 1din 42

ONLINE VOTING SYSTEM USING ANDROID MOBILE

ABSTRACT

During election period the percentage of casting of vote is becoming less day by day. The
Indian citizens those who are living in other countries can’t cast their vote, those whose are sick,
old aged and virtually handicap. Each and every person has their own right to vote as an Indian
citizen and it is also a rule followed in the country. We give an opportunity to the people those
who are not able to vote. Our application relies both on security and integrated web services to
vote from anywhere with all necessary proofs such as voter id, photo, adhar card, etc.

INTRODUCTION

The Indian citizens those who are living in other countries can’t cast their vote, those
whose are sick, old aged and virtually handicap. The people in urban areas have to travel a long
distance to the polling booth and cast their vote; because of these many old aged people and sick
people will not be able to cast their vote.

Our android application has a web service call enabled only to the available pooling city,
state or country on that particular date and to that particular working hours. The voter can cast
only one vote after that the session get closed immediately, and he can’t able to cast using any
one of the proof such as adhar card or voter id. The counting process and monitoring process are
managed by the administrator; the counting is done after casting of vote has been finished within
an hour. The system is more efficient and will have all kind of security technique such as
cryptography, etc.

EXISTING SYSTEM

The system used in existing is ballot machine which has been introduced to reduce the
paper work, human resources and fake vote. You might have been heard about re-polling process
because of electronic voting machine performance failure. The people in urban areas have to
travel a long distance to the polling booth and cast their vote; because of these many old aged
people and sick people will not be able to cast their vote.

PROPOSED SYSTEM

Our android application has a web service call enabled only to the available pooling city,
state or country on that particular date and to that particular working hours. The voter can cast
only one vote after that the session get closed immediately, and he can’t able to cast using any
one of the proof such as adhar card or voter id. The counting process and monitoring process are
managed by the administrator; the counting is done after casting of vote has been finished within
an hour. The system is more efficient and will have all kind of security technique such as
cryptography, etc.

SYSTEM ANALYSIS

User Voter Id Adhar Id

Admin Photo Capture

OTP
Counting

Vote
SYSTEM ARCHITECTURE

Admin

Rest service Cloud Server


DB

User

USE CASE DIAGRAM

Voter Id

Adhar Id

Voter Photo

User Counting Admin


CLASS DIAGRAM

Check Voter Id Check Adhar Id

VoterIDActivity.ja AdharIdActivity.j
va ava

OnCreate() OnCreate ()

Capture Activity List of


Nominators

PhotoCatureActi NominatorsActivi
vity.java ty.java

OnCreate() OnCreate()
ACTIVITY DIAGRAM

Start

Voter ID

Adhar ID

Capture
Photo

OTP

Vote
SEQUENCE DIAGRAM

Validate Voter ID Validate Adhar ID Photo Vote

Voter Id

Adhar ID Photo

MODULES

 ADMINISTRATOR
 USER
 VOTING
 COUNTING
 NOMINATION

MODULES DESCRIPTION

 Administrator
The administrator is responsible for the management of online voting system; the
application is developed in android. The nomination of parties and issuing of voter ids are
also managed by the web application. Both the voters and nominators proofs and their
crime reports are verified by the administrator and for only authorized users the voter id
and nomination receipt is issued by the web application.

 User
From the application itself the user is allowed to apply for voter id and after the
approval of the administrator only the voter id is issued and delivered through post. This
saves lot of time of the user’s and encourages lot of youngsters to apply for voter id from
their mobile phone.

 Voting
Only the authorized users are allowed to cast their vote after verifying their photo
with the submitted proof such as adhar card or voter id. The user is allowed to vote only
once and after once the vote is registered the session gets terminated by itself
automatically for that particular area which he originally belongs too.

 Counting
In counting module the counting of voted are done and the counting is carried out
by the administrator. The counting process also made simpler with the help of web
application which is running on the cloud severs and display the result on the
administrator dashboard.

 Nomination
The application of nomination for can be enrolled through android application
and after the approval of the administrator the certificate of nomination can be issued and
the nominator gets enrolled for the election process.

SYSTEM SPECIFICATION

Hardware Requirements

Processor : Dual-core 1 GHz Krait

Speed : 1.1 GHz


RAM : 512 MB (min)

Internal Memory : 4 GB

Device : Android Smart phone.

Software Requirements

Operating System : Android OS.

Technology Used : Android 4.1

Front End : Java.

IDE : Eclipse.

SOFTWARE DESCRIPTION

Java Technology
Java technology is both a programming language and a platform.

The Java Programming Language


The Java programming language is a high-level language that can be characterized by all
of the following buzzwords:

 Simple
 Architecture neutral
 Object oriented
 Portable
 Distributed
 High performance
 Interpreted
 Multithreaded
 Robust
 Dynamic
 Secure

With most programming languages, you either compile or interpret a program so that you
can run it on your computer. The Java programming language is unusual in that a program is
both compiled and interpreted. With the compiler, first you translate a program into an
intermediate language called Java byte codes —the platform-independent codes interpreted by
the interpreter on the Java platform. The interpreter parses and runs each Java byte code
instruction on the computer. Compilation happens just once; interpretation occurs each time the
program is executed. The following figure illustrates how this works.

You can think of Java byte codes as the machine code instructions for the Java Virtual
Machine (Java VM). Every Java interpreter, whether it’s a development tool or a Web browser
that can run applets, is an implementation of the Java VM. Java byte codes help make “write
once, run anywhere” possible. You can compile your program into byte codes on any platform
that has a Java compiler. The byte codes can then be run on any implementation of the Java VM.
That means that as long as a computer has a Java VM, the same program written in the Java
programming language can run on Windows 2000, a Solaris workstation, or on an iMac.
The Java Platform
A platform is the hardware or software environment in which a program runs.
We’ve already mentioned some of the most popular platforms like Windows 2000, Linux,
Solaris, and MacOS. Most platforms can be described as a combination of the operating
system and hardware. The Java platform differs from most other platforms in that it’s a
software-only platform that runs on top of other hardware-based platforms.

The Java platform has two components:


 The Java Virtual Machine (Java VM)
 The Java Application Programming Interface (Java API)

You’ve already been introduced to the Java VM. It’s the base for the Java platform
and is ported onto various hardware-based platforms.

The Java API is a large collection of ready-made software components that provide
many useful capabilities, such as graphical user interface (GUI) widgets. The Java API is
grouped into libraries of related classes and interfaces; these libraries are known as
packages. The next section, What Can Java Technology Do? Highlights what
functionality some of the packages in the Java API provide.
The following figure depicts a program that’s running on the Java platform. As the
figure shows, the Java API and the virtual machine insulate the program from the
hardware.
Native code is code that after you compile it, the compiled code runs on a specific
hardware platform. As a platform-independent environment, the Java platform can be a
bit slower than native code. However, smart compilers, well-tuned interpreters, and just-
in-time byte code compilers can bring performance close to that of native code without
threatening portability.

What Can Java Technology Do?


The most common types of programs written in the Java programming language are
applets and applications. If you’ve surfed the Web, you’re probably already familiar with
applets. An applet is a program that adheres to certain conventions that allow it to run
within a Java-enabled browser.

However, the Java programming language is not just for writing cute, entertaining applets
for the Web. The general-purpose, high-level Java programming language is also a
powerful software platform. Using the generous API, you can write many types of
programs.
An application is a standalone program that runs directly on the Java platform. A special
kind of application known as a server serves and supports clients on a network. Examples
of servers are Web servers, proxy servers, mail servers, and print servers. Another
specialized program is a servlet. A servlet can almost be thought of as an applet that runs
on the server side. Java Servlets are a popular choice for building interactive web
applications, replacing the use of CGI scripts. Servlets are similar to applets in that they
are runtime extensions of applications.
Instead of working in browsers, though, Servlets run within Java Web servers,
configuring or tailoring the server.
How does the API support all these kinds of programs? It does so with packages of
software components that provides a wide range of functionality. Every full
implementation of the Java platform gives you the following features:
 The essentials: Objects, strings, threads, numbers, input and output, data
structures, system properties, date and time, and so on.
 Applets: The set of conventions used by applets.
 Networking: URLs, TCP (Transmission Control Protocol), UDP (User Data gram
Protocol) sockets, and IP (Internet Protocol) addresses.
 Internationalization: Help for writing programs that can be localized for users
worldwide. Programs can automatically adapt to specific locales and be displayed
in the appropriate language.
 Security: Both low level and high level, including electronic signatures, public
and private key management, access control, and certificates.
 Software components: Known as JavaBeansTM, can plug into existing component
architectures.
 Object serialization: Allows lightweight persistence and communication via
Remote Method Invocation (RMI).
 Java Database Connectivity (JDBC TM): Provides uniform access to a wide range of
relational databases.
The Java platform also has APIs for 2D and 3D graphics, accessibility, servers,
collaboration, telephony, speech, animation, and more. The following figure depicts what
is included in the Java 2 SDK.
How will java technology change my life?

We can’t promise you fame, fortune, or even a job if you learn the Java programming
language. Still, it is likely to make your programs better and requires less effort than other
languages. We believe that Java technology will help you do the following:

 Get started quickly: Although the Java programming language is a powerful


object-oriented language, it’s easy to learn, especially for programmers already
familiar with C or C++.
 Write less code: Comparisons of program metrics (class counts, method counts,
and so on) suggest that a program written in the Java programming language can
be four times smaller than the same program in C++.
 Write better code: The Java programming language encourages good coding
practices, and its garbage collection helps you avoid memory leaks. Its object
orientation, its JavaBeans component architecture, and its wide-ranging, easily
extendible API let you reuse other people’s tested code and introduce fewer bugs.
 Develop programs more quickly: Your development time may be as much as
twice as fast versus writing the same program in C++. Why? You write fewer
lines of code and it is a simpler programming language than C++.
 Avoid platform dependencies with 100% Pure Java: You can keep your program
portable by avoiding the use of libraries written in other languages. The 100%
Pure JavaTM Product Certification Program has a repository of historical process
manuals, white papers, brochures, and similar materials online.
 Write once, run anywhere: Because 100% Pure Java programs are compiled into
machine-independent byte codes, they run consistently on any Java platform.
 Distribute software more easily: You can upgrade applets easily from a central
server. Applets take advantage of the feature of allowing new classes to be loaded
“on the fly,” without recompiling the entire program.
ODBC
Microsoft Open Database Connectivity (ODBC) is a standard programming interface for
application developers and database systems providers. Before ODBC became a de facto
standard for Windows programs to interface with database systems, programmers had to use
proprietary languages for each database they wanted to connect to. Now, ODBC has made the
choice of the database system almost irrelevant from a coding perspective, which is as it should
be. Application developers have much more important things to worry about than the syntax that
is needed to port their program from one database to another when business needs suddenly
change.
Through the ODBC Administrator in Control Panel, you can specify the particular
database that is associated with a data source that an ODBC application program is written to
use. Think of an ODBC data source as a door with a name on it. Each door will lead you to a
particular database. For example, the data source named Sales Figures might be a SQL Server
database, whereas the Accounts Payable data source could refer to an Access database. The
physical database referred to by a data source can reside anywhere on the LAN.
The ODBC system files are not installed on your system by Windows 95. Rather, they are
installed when you setup a separate database application, such as SQL Server Client or Visual
Basic 4.0. When the ODBC icon is installed in Control Panel, it uses a file called
ODBCINST.DLL. It is also possible to administer your ODBC data sources through a stand-
alone program called ODBCADM.EXE. There is a 16-bit and a 32-bit version of this program
and each maintains a separate list of ODBC data sources.

From a programming perspective, the beauty of ODBC is that the application can be
written to use the same set of function calls to interface with any data source, regardless of the
database vendor. The source code of the application doesn’t change whether it talks to Oracle or
SQL Server. We only mention these two as an example. There are ODBC drivers available for
several dozen popular database systems. Even Excel spreadsheets and plain text files can be
turned into data sources. The operating system uses the Registry information written by ODBC
Administrator to determine which low-level ODBC drivers are needed to talk to the data source
(such as the interface to Oracle or SQL Server). The loading of the ODBC drivers is transparent
to the ODBC application program. In a client/server environment, the ODBC API even handles
many of the network issues for the application programmer.
The advantages of this scheme are so numerous that you are probably thinking there must
be some catch. The only disadvantage of ODBC is that it isn’t as efficient as talking directly to
the native database interface. ODBC has had many detractors make the charge that it is too slow.
Microsoft has always claimed that the critical factor in performance is the quality of the driver
software that is used. In our humble opinion, this is true. The availability of good ODBC drivers
has improved a great deal recently. And anyway, the criticism about performance is somewhat
analogous to those who said that compilers would never match the speed of pure assembly
language. Maybe not, but the compiler (or ODBC) gives you the opportunity to write cleaner
programs, which means you finish sooner. Meanwhile, computers get faster every year.

JDBC
In an effort to set an independent database standard API for Java; Sun Microsystems
developed Java Database Connectivity, or JDBC. JDBC offers a generic SQL database access
mechanism that provides a consistent interface to a variety of RDBMSs. This consistent interface
is achieved through the use of “plug-in” database connectivity modules, or drivers. If a database
vendor wishes to have JDBC support, he or she must provide the driver for each platform that the
database and Java run on.
To gain a wider acceptance of JDBC, Sun based JDBC’s framework on ODBC. As you
discovered earlier in this chapter, ODBC has widespread support on a variety of platforms.
Basing JDBC on ODBC will allow vendors to bring JDBC drivers to market much faster than
developing a completely new connectivity solution.
JDBC was announced in March of 1996. It was released for a 90 day public review that
ended June 8, 1996. Because of user input, the final JDBC v1.0 specification was released soon
after.
The remainder of this section will cover enough information about JDBC for you to know what it
is about and how to use it effectively. This is by no means a complete overview of JDBC. That
would fill an entire book.

What is Database?

A database is a separate application that stores a collection of data. Each database has one or
more distinct APIs for creating, accessing, managing, searching, and replicating the data it holds.

Other kinds of data stores can be used, such as files on the file system or large hash tables in
memory but data fetching and writing would not be so fast and easy with those types of systems.

So now days we use relational database management systems (RDBMS) to store and manager
huge volume of data. This is called relational database because all the data is stored into different
tables and relations are established using primary keys or other keys known as foreign keys.

A Relational DataBase Management System (RDBMS) is software that:

 Enables you to implement a database with tables, columns, and indexes.


 Guarantees the Referential Integrity between rows of various tables.

 Updates the indexes automatically.

 Interprets an SQL query and combines information from various tables.

RDBMS Terminology:

Before we proceed to explain MySQL database system, lets revise few definitions related to
database.

 Database: A database is a collection of tables, with related data.


 Table: A table is a matrix with data. A table in a database looks like a simple spreadsheet.

 Column: One column (data element) contains data of one and the same kind, for
example the column postcode.
 Row: A row (= tuple, entry or record) is a group of related data, for example the data of
one subscription.

 Redundancy: Storing data twice, redundantly to make the system faster.

 Primary Key: A primary key is unique. A key value can not occur twice in one table.
With a key you can find at most one row.

 Foreign Key: A foreign key is the linking pin between two tables.

 Compound Key: A compound key (composite key) is a key that consists of multiple
columns, because one column is not sufficiently unique.

 Index: An index in a database resembles an index at the back of a book.

 Referential Integrity: Referential Integrity makes sure that a foreign key value always
points to an existing row.

MySQL Database:

MySQL is a fast, easy-to-use RDBMS used being used for many small and big businesses.
MySQL is developed, marketed, and supported by MySQL AB, which is a Swedish company.
MySQL is becoming so popular because of many good reasons.

 MySQL is released under an open-source license. So you have nothing to pay to use it.
 MySQL is a very powerful program in its own right. It handles a large subset of the
functionality of the most expensive and powerful database packages.

 MySQL uses a standard form of the well-known SQL data language.

 MySQL works on many operating systems and with many languages including PHP,
PERL, C, C++, JAVA etc.

 MySQL works very quickly and works well even with large data sets.
 MySQL is very friendly to PHP, the most appreciated language for web development.

 MySQL supports large databases, up to 50 million rows or more in a table. The default
file size limit for a table is 4GB, but you can increase this (if your operating system can
handle it) to a theoretical limit of 8 million terabytes (TB).

 MySQL is customizable. The open source GPL license allows programmers to modify the
MySQL software to fit their own specific environments.

Before You Begin:

Before you begin this tutorial you should have a basic knowledge of the information covered in
our PHP and HTML tutorials.

This tutorial focuses heavily on using MySQL in a PHP environment. Many examples given in
this tutorial will be useful for PHP Programmers.

We recommend you check our PHP Tutorial for your reference.

Android is an operating system based on the Linux kernel, and designed primarily
for touch screen mobile devices such as smart phones and tablet computers. Initially developed
by Android, Inc., which Google backed financially and later bought in 2005, Android was
unveiled in 2007 along with the founding of the Open Handset Alliance—a consortium
of hardware, software, and telecommunication companies devoted to advancing open
standards for mobile devices The first publicly available smart phone running Android, the HTC
Dream, was released on October 22, 2008.

The user interface of Android is based on direct manipulation, using touch inputs that
loosely correspond to real-world actions, like swiping, tapping, pinching and reverse pinching to
manipulate on-screen objects. Internal hardware such
as accelerometers, gyroscopes and proximity sensors are used by some applications to respond to
additional user actions, for example adjusting the screen from portrait to landscape depending on
how the device is oriented. Android allows users to customize their home screens with shortcuts
to applications and widgets, which allow users to display live content, such as emails and
weather information, directly on the home screen. Applications can further send notifications to
the user to inform them of relevant information, such as new emails and text messages.

Android's source code is released by Google under the Apache License; this permissive
licensing allows the software to be freely modified and distributed by device manufacturers,
wireless carriers and enthusiast developers. Most Android devices ship with a combination of
open source and proprietary software. As of July 2013, Android has the largest number of
applications ("apps"), available for download in Google Play store which has had over 1 million
apps published, and over 50 billion downloads. A developer survey conducted in April–May
2013 found that Android is the most used platform among developers: it is used by 71% of the
mobile developer’s population.

Android is popular with technology companies which require a ready-made, low-cost and
customizable operating system for high-tech devices. Despite being primarily designed for
phones and tablets, it also has been used in televisions, games consoles, digital cameras and other
electronics. Android's open nature has encouraged a large community of developers and
enthusiasts to use the open-source code as a foundation for community-driven projects, which
add new features for advanced users or bring Android to devices which were officially, released
running other operating systems.

As of May 2012, Android became the most popular mobile OS, having the largest
installed base, and is a market leader in most countries including the United States; there it has
had the highest installed base of mobile phones for years. In the third quarter of 2013, Android's
share of the global smartphone shipment market—led by Samsung products—was 81.3%, the
highest ever. In most markets Android-powered phones are the most popular comprising more
than half of the overall smartphone sales, including the United States market starting with the
September–November 2013 period. The operating system's success has made it a target for
patent litigation as part of the so-called "smartphone wars" between technology companies.As of
September 2013, one billion Android devices have been activated.
SOFTWARE STACK

On top of the Linux kernel, there are the middleware, libraries and APIs written in C,
and application software running on anapplication framework which includes Java-compatible
libraries based on Apache Harmony. Android uses the Dalvik virtual machine with just-in-time
compilation to run Dalvik "dex-code" (Dalvik Executable), which is usually translated from
the Java bytecode. Android 4.4 also supports new experimental runtime virtual machine, ART,
which is not enabled by default.

Android uses Bionic in place of a standard C library, originally developed by Google


specifically for Android, as a derivation of theBSD's standard C library code. Bionic has several
major features specific to the Linux kernel, and its development continues independently of other
Android's source code bases. The main benefits of using Bionic instead of the GNU C
Library (glibc) oruClibc are its different licensing model, smaller runtime footprint, and
optimization for low-frequency CPUs.

Android does not have a native X Window System by default nor does it support the full
set of standard GNU libraries, and this makes it difficult to port existing Linux applications or
libraries to Android. Support for simple C and SDL applications is possible by injection of a
small Java shim and usage of the JNI like, for example, in the Jagged Alliance 2 port for
Android.

OPEN-SOURCE COMMUNITY

Android has an active community of developers and enthusiasts who use the Android
Open Source Project (AOSP) source code to develop and distribute their own modified versions
of the operating system. These community-developed releases often bring new features and
updates to devices faster than through the official manufacturer/carrier channels, albeit without
as extensive testing or quality assurance; provide continued support for older devices that no
longer receive official updates; or bring Android to devices that were officially released running
other operating systems, such as the HP TouchPad. Community releases often come pre-
rooted and contain modifications unsuitable for non-technical users, such as the ability
to overclock or over/undervolt the device's processor. CyanogenMod is the most widely used
community firmware, and acts as a foundation for numerous others.
Historically, device manufacturers and mobile carriers have typically been unsupportive
of third-party firmware development. Manufacturers express concern about improper functioning
of devices running unofficial software and the support costs resulting from this. Moreover,
modified firmwares such as CyanogenMod sometimes offer features, such as tethering, for which
carriers would otherwise charge a premium. As a result, technical obstacles including
locked bootloaders and restricted access to root permissions are common in many devices.
However, as community-developed software has grown more popular, and following a statement
by the Librarian of Congress in the United States that permits the "jailbreaking" of mobile
devices, manufacturers and carriers have softened their position regarding third party
development, with some, including HTC, Motorola, Samsung and Sony, providing support and
encouraging development.

As a result of this, over time the need to circumvent hardware restrictions to install
unofficial firmware has lessened as an increasing number of devices are shipped with unlocked
or unlockable bootloaders, similar to the Nexus series of phones, although usually requiring that
users waive their devices' warranties to do so. However, despite manufacturer acceptance, some
carriers in the US still require that phones are locked down.

The unlocking and "hackability" of smartphones and tablets remains a source of tension between
the community and industry, with the community arguing that unofficial development is
increasingly important given the failure of industry to provide timely updates and/or continued
support to their devices.

CODE

VoterIdActivity.java
package com.apps.onlinevoting;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.json.JSONArray;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.apps.ResourceBundle.AppBundle;

public class VoterIdActivity extends Activity {

private Button nextbutton = null;


private EditText voteridEdittext = null;
private static String IPADDRESS = null;
private static String PORTNO = null;

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voter_id);

// Resource Bundle
IPADDRESS = new AppBundle().loadpropertyfile("IPADDRESS", "config");
PORTNO = new AppBundle().loadpropertyfile("PORTNO", "config");

// to connect to network
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

// button declaration
nextbutton = (Button) findViewById(R.id.vNext_Button);

// edit text declaration


voteridEdittext = (EditText) findViewById(R.id.voterid_editText);

// signout button action


nextbutton.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {

if((voteridEdittext.getText().toString()!=null) && (!
voteridEdittext.getText().toString().equals("")))
{
InputStream objInputStream = null;

try
{
JSONObject objJSONRequest = new JSONObject();

// request
objJSONRequest.put("Sqlbuffer","SELECT
VoterCardID#IsActive FROM votercard WHERE VoterCardID =
'"+voteridEdittext.getText().toString()+"' ");
objJSONRequest.put("Fields", "2");
objJSONRequest.put("FieldValues","VoterCardID#IsActive");

Log.i("JSON Before:",
objJSONRequest.toString());

// dispatch to web service to insert user


details
HttpClient httpclient = new
DefaultHttpClient();
HttpResponse reponse;

Toast.makeText(
getApplicationContext(),
"http://" + IPADDRESS + ":" +
PORTNO
+
"/VotingService/rest/votingservice/getData",
Toast.LENGTH_SHORT).show();

HttpPost httppost = new HttpPost("http://" +


IPADDRESS + ":" + PORTNO + "/VotingService/rest/votingservice/getData");
HttpEntity entity;

Log.i("JSON After hit:",


objJSONRequest.toString());

try {
StringEntity se = new
StringEntity(objJSONRequest.toString());
se.setContentEncoding(new
BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
httppost.setHeader("content-type",
"application/json");
httppost.setEntity(se);
reponse = httpclient.execute(httppost);
entity = reponse.getEntity();

if (entity != null) {
objInputStream =
entity.getContent();
String result =
convertStreamToString(objInputStream);

JSONObject objJSONResponse = new


JSONObject(result);

JSONArray objJSONArrayResponse =
objJSONResponse
.getJSONArray("Resp
onse");

if
(objJSONArrayResponse.length() > 0)
{
int size =
objJSONArrayResponse.length();

Log.i("objJSONArrayResponse", "" + size);

for (int i = 0; i < size;


i++)
{
JSONObject
another_json_object = objJSONArrayResponse .getJSONObject(i);

if(!
another_json_object.getString("VoterCardID").equalsIgnoreCase("No Record Found!"))
{

if(another_json_object.getString("IsActive").equalsIgnoreCase("0"))
{
Intent intent
= new Intent(getApplicationContext(), AdharIdActivity.class);

intent.putExtra("VotersID",
another_json_object.getString("VoterCardID").trim());

startActivity(intent);
}
else
{

Toast.makeText(getApplicationContext(), "This candidate voted already.",


Toast.LENGTH_SHORT).show();
}
}
else
{

Toast.makeText(getApplicationContext(), "Incorrect Voter ID.",


Toast.LENGTH_SHORT).show();
}
}
} else {
// display in short period
of time

Toast.makeText(getApplicationContext(),
"Incorrect
Voter ID!",

Toast.LENGTH_SHORT).show();
}
}

} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Exception :" + e,

Toast.LENGTH_SHORT).show();
} finally {
objInputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
else
{
//display in short period of time
Toast.makeText(getApplicationContext(), "Please all
empty fields!", Toast.LENGTH_SHORT).show();
}
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_voter_id, menu);
return true;
}

public static String convertStreamToString(InputStream is) {


BufferedReader bs = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String Line = "";

try {
while ((Line = bs.readLine()) != null) {
sb.append(Line + "/n");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}

return sb.toString();
}

OTPActivity.java
package com.apps.onlinevoting;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.apps.ResourceBundle.AppBundle;

public class OTPActivity extends Activity {

private static String IPADDRESS = null;


private static String PORTNO = null;
private EditText otpEdittext = null;
private Button nextButton = null;
public static JSONObject objJSONObjects = null;
private static String studentid = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp);

//Resource Bundle
IPADDRESS = new AppBundle().loadpropertyfile("IPADDRESS", "config");
PORTNO = new AppBundle().loadpropertyfile("PORTNO", "config");
// edit text declaration
otpEdittext = (EditText) findViewById(R.id.otp_editText);
nextButton = (Button) findViewById(R.id.otpnext_Button);

// to connect to network
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

// join button action


nextButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {

try
{
String regnos = getIntent().getStringExtra("VotersID");

//get user id
objJSONObjects = new JSONObject();

studentid = otpEdittext.getText().toString().trim();

objJSONObjects.put("Sqlbuffer", "SELECT
VoterCardID#Voter_OTP FROM votercard where VoterCardID = '"+regnos+"' AND Voter_OTP
= '"+studentid+"'");
objJSONObjects.put("Fields", "2");
objJSONObjects.put("FieldValues", "VoterCardID#Voter_OTP");

Toast.makeText(getApplicationContext(),
objJSONObjects.toString(), Toast.LENGTH_SHORT).show();
//dispatch to web service to insert user details
HttpClient httpclient2 = new DefaultHttpClient();
HttpResponse reponse2;

HttpPost httppost2 = new


HttpPost("http://"+IPADDRESS+":"+PORTNO+"/VotingService/rest/votingservice/getData");
HttpEntity entity2;

try
{
StringEntity se2 = new
StringEntity(objJSONObjects.toString());
se2.setContentEncoding(new
BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost2.setHeader("content-type",
"application/json");
httppost2.setEntity(se2);
reponse2 = httpclient2.execute(httppost2);
entity2 = reponse2.getEntity();

if(entity2 != null)
{
InputStream is2 =
entity2.getContent();
String result =
convertStreamToString(is2);

Log.i("result:", result);
JSONObject objJSONResponse =
new JSONObject(result);

JSONArray objJSONArrayResponse =
objJSONResponse.getJSONArray("Response");

if(objJSONArrayResponse.length()
> 0)
{
int size =
objJSONArrayResponse.length();

for (int i1 = 0; i1 < size; i1+


+)
{

JSONObject
another_json_object = objJSONArrayResponse.getJSONObject(i1);

Log.i("Result:",
another_json_object.toString());

if(!
another_json_object.getString("Voter_OTP").equalsIgnoreCase("No Record Found!"))
{

Intent intent = new


Intent(getApplicationContext(), VotingActivity.class);

intent.putExtra("VotersID", getIntent().getStringExtra("VotersID").toString());
intent.putExtra("AdharID", getIntent().getStringExtra("AdharID").toString());

intent.putExtra("PhotoPath", "");

intent.putExtra("Screen", "User Home");


startActivity(intent);
}
else
{

Toast.makeText(getApplicationContext(), "Incorrect OTP.",


Toast.LENGTH_SHORT).show();
}
}

is2.close();
}

}
catch(Exception e)
{
e.printStackTrace();

}
catch(Exception e)
{
e.printStackTrace();
}

}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_otp, menu);
return true;
}

public static String convertStreamToString(InputStream is)


{
BufferedReader bs = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String Line = "";

try
{
while((Line = bs.readLine()) != null)
{
sb.append(Line + "/n");
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
is.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}

return sb.toString();
}
}

SCREEN SHOTS

SOFTWARE FEASIBILITY

FEASIBILITY STUDY:

The feasibility of the project is analyzed in this phase and business proposal is

put forth with a very general plan for the project and some cost estimates. During system

analysis the feasibility study of the proposed system is to be carried out. This is to ensure that the

proposed system is not a burden to the company. For feasibility analysis, some understanding of

the major requirements for the system is essential.


Three key considerations involved in the feasibility analysis are

 ECONOMICAL FEASIBILITY
 TECHNICAL FEASIBILITY
 SOCIAL FEASIBILITY

ECONOMICAL FEASIBILITY

This study is carried out to check the economic impact that the system will have on the
organization. The amount of fund that the company can pour into the research and development
of the system is limited. The expenditures must be justified. Thus the developed system as well
within the budget and this was achieved because most of the technologies used are freely
available. Only the customized products had to be purchased.

TECHNICAL FEASIBILITY

This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand on the available
technical resources. This will lead to high demands on the available technical resources. This
will lead to high demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this system.

SOCIAL FEASIBILITY

The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system and
to make him familiar with it. His level of confidence must be raised so that he is also able to
make some constructive criticism, which is welcomed, as he is the final user of the system.
FUNCTIONAL REQUIREMENTS:

Functional requirements specify which output file should be produced from the given
file they describe the relationship between the input and output of the system, for each
functional requirement a detailed description of all data inputs and their source and the range of
valid inputs must be specified.

NON FUNCTIONAL REQUIREMENTS:

Describe user-visible aspects of the system that are not directly related with the
functional behavior of the system. Non-Functional requirements include quantitative constraints,
such as response time (i.e. how fast the system reacts to user commands.) or accuracy ((.e. how
precise are the systems numerical answers.)

PSEUDO REQUIREMENTS:

The client that restricts the implementation of the system imposes these requirements.
Typical pseudo requirements are the implementation language and the platform on which the
system is to be implemented. These have usually no direct effect on the user’s view of the
system.

SYSTEM TESTING

For testing purpose we use “Logcat” along with normal testing as mentioned below.

LOGCAT:

Logcat feature is available in android for developers test. Where this logcat feature is available
in DDMS.

DDMS:
On Android, every application runs in its own process, each of which runs in its own
virtual machine (VM). Each VM exposes a unique port that a debugger can attach to.

When DDMS starts, it connects to adb. When a device is connected, a VM monitoring service is
created between adb and DDMS, which notifies DDMS when a VM on the device is started or
terminated. Once a VM is running, DDMS retrieves the VM's process ID (pid), via adb, and
opens a connection to the VM's debugger, through the adb daemon (adbd) on the device. DDMS
can now talk to the VM using a custom wire protocol.

DDMS assigns a debugging port to each VM on the device. Typically, DDMS assigns port 8600
for the first debuggable VM, the next on 8601, and so on. When a debugger connects to one of
these ports, all traffic is forwarded to the debugger from the associated VM. You can only attach
a single debugger to a single port, but DDMS can handle multiple, attached debuggers.

By default, DDMS also listens on another debugging port, the DDMS "base port" (8700, by
default). The base port is a port forwarder, which can accept VM traffic from any debugging port
and forward it to the debugger on port 8700. This allows you to attach one debugger to port
8700, and debug all the VMs on a device. The traffic that is forwarded is determined by the
currently selected process in the DDMS Devices view.

The following screenshot shows a typical DDMS screen in Eclipse. If you are starting DDMS
from the command line, the screen is slightly different, but much of the functionality is identical.
Notice that the highlighted process, com.tdrive that is running in the emulator has the debugging
port 8700 assigned to it as well as 8606. This signifies that DDMS is currently forwarding port
8606 to the static debugging port of 8700.
Then Logcat is accessed using some “Log Classes”

Log is a logging class that you can utilize in your code to print out messages to the LogCat.
Common logging methods include:

 v(String, String) (verbose)

 d(String, String) (debug)

 i(String, String) (information)

 w(String, String) (warning)

 e(String, String) (error)

UNIT TESTING
Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision branches and
internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests perform
basic tests at component level and test a specific business process, application, and/or system
configuration. Unit tests ensure that each unique path of a business process performs accurately
to the documented specifications and contains clearly defined inputs and expected results.

INTEGRATION TESTING

Integration tests are designed to test integrated software components to determine if they
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown by successfully unit testing, the combination of components is
correct and consistent. Integration testing is specifically aimed at exposing the problems that
arise from the combination of components.

FUNCTIONAL TESTING

Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user manuals.

Functional testing is centered on the following items:

Valid Input: identified classes of valid input must be accepted.

Invalid Input: identified classes of invalid input must be rejected.

Functions: identified functions must be exercised.

Output: identified classes of application outputs must be exercised.


Systems/Procedures: interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements, key functions, or


special test cases. In addition, systematic coverage pertaining to identify Business process flows;
data fields, predefined processes, and successive processes must be considered for testing.
Before functional testing is complete, additional tests are identified and the effective value of
current tests is determined.

SYSTEM TESTING

System testing ensures that the entire integrated software system meets requirements. It
tests a configuration to ensure known and predictable results. An example of system testing is the
configuration oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.

CONCLUSION
T h e s y s t e m p r o p o s e d i s v e r y e ff i c i e n t a n d h a s v a r i o u s a d v a n t a g e s t o
increase the voting percentage and to make people to become aware of
voting technique and to choose the right person to lead them.

S-ar putea să vă placă și