Sunteți pe pagina 1din 71

BLUETOOTH CHATTING APP

A DISSERTATION

Submitted in partial fulfillment of the


requirement for the award of the degree
Of

MASTER OF COMPUTER APPLICATION

Submitted by

PUNESH SHARMA

Under the guidance of

Mr. JAVED WASIM Mr. MANI JI


(ASSISTANT PROFESOR) (ANDROID DEVELOPER)

DEPARTMENT OF COMPUTER APPLICATIONS


INSTITUTE OF ENGINEERING AND TECHNOLOGY
BESWAN, ALIGARH-202145 (U.P) INDIA
May, 2017
Format1.1
Approval Sheet

This Dissertation entitled Bluetooth Chatting app by Punesh Sharma is approved


for the degree of Master in Computer Application.

Examiners
________________________
________________________
________________________
Supervisor (s)
Mr. JAVED WASIM

Chairman
________________________
Date :____________
Place :____________
Format 1.2

DECLARATION

I declare that this written submission represents my ideas in my own words and where others' ideas
or words have been included, I have adequately cited and referenced the original sources. I also
declare that I have adhered to all principles of academic honesty and integrity and have not
misrepresented or fabricated or falsified any idea/data/fact/source in my submission. I understand
that any violation of the above will be cause for disciplinary action by the Institute and can also
evoke penal action from the sources which have thus not been properly cited or from whom proper
permission has not been taken when needed.

_________________________________
(Signature)
Punesh sharma
(Roll No. 20150980)
Date: __________
CERTIFICATE Format 1.3

This is certified that the dissertation titled BLUETOOTH CHATT ING APP
by PUNESH SHARMA Degree in partial fulfillment of the requirements for the
award of MASTER IN COMPUTER APPLICATION is an original work carried
out by him/her under my/our supervision and guidance. It is certified that the work has
not been submitted anywhere else for the award of any other diploma or degree of this
or any other University.

Supervisor
(Name & Signature)

Co-Supervisor
(Name & Signature)
ACKNOWLEDGEMENT

I sincerely thank MCN SOLUTIONS PVT LTD for providing me the project training and all
necessary resources and expertise for this purpose.

I am deeply grateful to MANI JI, Android Developer who gave me opportunity to work under
his able guidance. I sincerely thank him for showing me direction and constantly providing me with
words of inspiration.

I am heartily thankful to, Dr. SUBODH SHARMA (HOD of DCA, IET Mangalayatan
University Aligarh U.P) for showing me direction and constantly providing me with words of
inspiration.

I am deeply grateful to Mr. JAVED WASIM who gave me opportunity to work under his able
guidance. I sincerely thank him for showing me direction and constantly providing me with words of
inspiration finally I would like to thanks my Parents, Friends and Relatives for their moral support,
appreciation and encouragement that made the project a success.

PUNESH SHARMA
Enroll.No.

20150980
Format1.4

TABLE OF CONTENTS
1. IntroductionPage no. 07

2. About the Organization.Page no. 08

3. Technology Used ...Page no. 09


3.1About the Technology
(a) Brief Description of Different modules
(b)Brief Description of Different Widgets
3.2Glade-The Interface Designer
3.3Data Base Used

4. REQUIREMENT ANALYSIS
4.1 Problem Statement......... Page no. 11
4.2 The Challenge- Where to begin... Page no. 12
4.3Software and system requirement specification Page no. 13
4.4System Requirement. Page no. 14

5. System Design and Algorithm Page no. 20

6. Coding and forms Page no. 26

7. Testing and Implementation Page no. 68

8. Conclusions, Limitation and Future Scope Page no. 69


8.1Conclusion.. Page no. 70
8.2LimitationPage no. 71
8.3Future ScopePage no. 72

9. References (Book, Journal, Research Papers, Websites, etc.) Page no. 73

10.Appendix A..Page no. 75


11.
Bluetooth Chat App
1-Introduction

It's secure; this app allows two Android devices to carry out two-way text chat over Bluetooth. It
demonstrates all the fundamental Bluetooth API capabilities, such as: (1) Scanning for other
Bluetooth devices (2) Querying the local Bluetooth adapter for paired Bluetooth devices (3)
Establishing RFCOMM channels/sockets (4) Connecting to a remote device (5) Transferring data
over Bluetooth.

Bluetooth chat is a messaging application that uses Bluetooth as the


connection method, Bluetooth does not require Internet connection, and this
method of messaging has no cost.

You dont have 3G or cannot find Wi-Fi? With this application you can easily
connect via Bluetooth to anyone nearby and start chatting!
It connects 2 phones in a second and it works in a range of about 50 meters
depending on the environment (Bluetooth does not like walls and closed
doors).

This can be used to send short messages over short distances. Now you can
stay in touch with your friends without paying single bucks. It enables free
chatting. Messages are sent directly between devices. The distance depends
on the devices. Smart Bluetooth Chat is a messaging app. It enables its users
to send messages. Enjoy talking to your friends without Wi-Fi or Internet.

Just pair two android devices using Bluetooth. You can initiate, fast, and easy
to use.

2-About the Organization

Company Profile

MCN Solutions is a rapidly growing software development company


focused on delivering the best and most cost-effective solutions for Software
Development, IT Consulting, Publishing and Training. We have offices in USA
and India which helps our clients to access our developers immediately. MCN
Solutions specializes in Microsoft .NET and other Microsoft cutting-edge
technologies. MCN Solutions is dedicated helping enterprises reduce their
software development cost and provide high quality and excellent productive
development. We are working on most prestigious software projects and
working with very professional clients too. In pipeline we have projects that
are related to latest technological trends in the software fields. Our services
offer significantly higher value benefits focusing on solving the unique and
challenging intricacies of building and supporting cutting-edge software
products. Our innovative approach, coupled with our core engineering
strength, aims at "exceeding the expectations of the clients", consistently
and continuously.

Latest and Cutting Edge

MCN Solutions specializes in Microsoft .NET technologies using Visual


Studio .NET and later versions. Our area of expertise includes:

C#, Visual Basic .NET, ASP.NET, ADO.NET, GDI+, Windows Forms, ASP.NET
Web Forms, Web Services, Tablet PC, Pocket PC, Windows, CR.NET, .NET
Multithreading, DirectX, SQL Server, .NET Remoting, Speech .NET

Fixed Cost Project

MCN Solutions provides turnkey software development, which is typically


pursuant to fixed-price, fixed-time frame contracts. The projects vary in size
and may involve the development of new applications or new functions for
existing software applications. Each development project typically would
involve the entire software development life cycle (SDLC) process, including
gathering requirement and specifications, analysis and design, prototyping,
coding, system, and integration testing, installation and deployment, and
maintenance.

In this type of projects, MCN Solutions will give an estimated time and cost
and we deliver the project within the specified duration.

3-Technology Used

In this app the technology used is Android.

What is Android?

Android is software for mobile phones, tablets and a growing range of


devices encompassing everything from wearable computing to in-car
entertainment. It launched in 2003 and is the worlds most popular mobile
operating system (OS).

Android is an open source project (led by Google but it doesn't belong to


them) called AOSP (Android Open Source Project). Google uses this project as
a base to create its version of Android, which is then used by the other
manufacturers.

As an OS, Android's job is to act as a translator between you and your


gadget. When you take a photo, Android provides the button you tap and
tells the phone what to do when you tap it. When you make or receive a call,
Android tells your phone how to do that. When you play a game, Android tells
the game what movements youre making and what buttons youre pressing.
Its like Windows, but for mobile devices.

The Android software itself is developed in conjunction with Google, who


releases major updates to the platform every year. Manufacturers which run
Android on their phones include Samsung, Huawei, Sony, Lenovo, HTC, LG
and many others; it's currently operational on more than one billion devices.

Where does Android come from?

It comes from Google, who actually acquired Android in 2005 (no, Google
didn't invent it). The search giant performs regular updates along with an
annual major update.The operating system is based on the Linux kernel if
you have friends who work in IT, you may have heard of it. This is the GNU /
Linux operating system based structure, which is a unix type system
(portable operating system, multitasking and multi-user). The Linux kernel is
one of the most prominent examples of free software.

Why does Android look different on each phone?

Android doesn't look different on every device, but it does have a number of
different versions. Android is open-source, which means that manufacturers
are free to customize the software and make it their own.

What are the advantages of Android?

Android Google Developer

The biggest advantage of the Android is Google. Android operating system


is owned by Google. Google is one of the most trusted and reputed product
on the internet. The name Google provide lots of trust for the users to buy
Android device.

Android Users Billions of Users

Android is the most used mobile operating system. It is used by over billion
people. Android is also the fastest growing operating system on the earth.
Android has billions of users. A number of users increase the number of
applications and software under the name of Android.

Android Multitasking

Most of us love this feature of the android. Users can do lots of tasks at once.
Users can open several applications at once and manage them all too.
Android has great UI which makes easy for users to do multitasking.

Disadvantages of Android studio

Android Battery Drain

Android handset is considered as one of the most battery consuming


operating systems. In the android operating system, there are plenty of
process running in the background which results in the quick draining of the
battery. It is hard to stop these applications as the majority of them are
system applications.

Android Malware/Virus/Security

Android device is not considered safe as compared to other applications. It is


easy to target any Andoird Phoneand every day millions of attempts are
done on Android phone. Hackers keep on trying to steal your personal
information.

4-REQUIREMENT ANALYSIS

Problem statement

In the growing ecosystem of mobile apps, it is critically important for mobile


app developers to understand what works and what doesnt work. We will
look into some of the major problems faced by mobile app developers.

1. Software Fragmentation: There are many Android OS


versions which developers find hard to keep up with when it comes to
app development. It is impractical to focus only on the most recent
Android version as not all users may have upgraded to the most recent
OS.
2. Hardware Fragmentation: This becomes a big Android app
development challenge since there are nearly 170+ devices running
the OS. Each device has different features with respect to keyboard
forms, screen size, camera buttons, etc., making it a development
nightmare.

3. No Software/Hardware Standardization: The huge number of


devices running Android gives rise to another Android app
development challengelack of software/hardware standardization
across the devices. This becomes a nightmare for developers as each
device has a different function for a different button.

4. Several Carriers: Android app development service providers should


know that there are many carriers available for the Android OS, each
with the freedom to modify the OS for their purposes. This only
multiplies the fragmentation problems for developers.

5. Security: Unlike Apples strict guidelines for app development, no


such governance exists for Android apps. As a result, many malware
problems arise and software/hardware fragmentation only makes fixing
the problems more difficult. This gives rise to tremendous amounts of
security issues.

6. Market Research Costs: One of the biggest Android app


development challenges for developers is the cost behind market
research. Understanding the end user is key to Android app
development, but can require a lot of research, making it costly for
developers.

7. Patent Issues: The recent lawsuits indicate that several Android


features may be declared as violation of patent issues. This can
become a big Android app development challenge for developers.

8. Android Market Search Engine: One of the major Android app


development challenges for developers is the Android marketplace.
Android has more than 8 million apps on its marketplace today and
getting your app visible amongst them is a challenge. As a result, even
with a great android app developed, if you dont pay attention to its
promotion, you may lose out on gaining any traction.
The Challenge-Where to begin

If you are planning to develop an app, your focus should be more on what
not to do than on what to do. There are several challenges faced by
developers every time they start working on a new mobile app.

1. Creating Apps which Get Noticed: Theres immense competition in the


mobile app market and honestly, its very crowded. Thus, theres a constant
pressure to create apps which get noticed. After all, you dont want to get
lost.

Solution: Create an app which looks great. Include graphics, usable


features, and intuitive design. Aim at providing a wholesome experience.
Take cues from successful apps in your niche to understand what clicks with
users. Answer the following questions, and youll know if your idea can crack
into this competitive market.

Who is my target group?

What is the aim of the app?

Which function does the app have?

Is the app absolutely new or does it improve an existing one or is it an

add-on etc.? (Analyze the innovation level, do some research!)

Is there a market for the app? (Do a competitor and/or benchmark

analysis or user survey!)

What will be the price of the app? (Analyze the profitability!)


Where will the app be sold? (Selling via the most popular app stores or

via extra channels and other/own websites?)

What is it that I am offering and no one has offered before?

2. Getting the App Funded: Now that you have a killer app idea, how do
you get it funded? Depending on the nature of the app, the cost of
development can be anywhere from $3,000 to $150,000. How do you get the
money?

Solution: Before you meet the right investors, there are several ways you
can raise funds. Approach your social circle, apply for loans, ask friends and
relatives and look for joint venture companies which invest in such apps. You
may also try crowdfunding platforms like Kickstarter and AppBackrare great
starting points. App contests can also be the way to go if you have a winning
idea in mind.

3. Dealing with the Screen Real Estate: Users have many different
devices with different screen sizes. And designing only for the latest platform
is a big no-no. So the challenge is to create an app which can run across as
many devices as possible. Countless mobile platforms have different
limitations based on screen sizes, OS requirements, embedded technologies,
pixel intensities etc. However, its not only about the devices. You need to
consider the OS as well. iOS, Android and Windows each of these three
main systems has its own UI objects and patterns. So be prepared for some
bug fixing every now and then.
Solution: Responsive Design. It gives screens more liquidity and thus can be
adjusted to suit different formats and various screen sizes. Facebook is a
great example.
To deal with technical OS issues, having a marked testing phase helps.
Releasing a beta version of the app is also recommended.

4. Making the App Interactive: Interactions are just as important as


responsive design. Mobile devices today are laden with high-tech sensors,
thus offering a plethora of opportunities. So make the most of these sensors!
Creating interactions, however, is time-consuming and can be a challenge to
deal with during the design phase.

Solution: Consider interactions well in advance to save time during the


design phase. And aim for a comprehensive app experience. Dont restrict
yourself to tap and swipe gestures. Use buttons with various click options
and consider overlays to display additional information. Bring more tangible
interactions like titling, shaking and flipping into play, which allow the app to
respond to position, direction and environment of the device and trigger
some action.

5. Keeping it Simple and Clear: An app that makes users think isnt a
good app. The challenge is to design an application which is self-explanatory.
But keep in mind that if the functioning of the app is clears to you (the
developer), it isnt necessarily clear to the users as well.
Solution: The trick is to use a simple and clear structure and give brief
instructions, tutorials etc. explaining what needs to be done and how. You
may use thumbnails and icons to display information in a compact manner.
However, make sure these icons correspond to the native UI elements of
each OS. You can refer to the UI guidelines provided by platforms like
Android, Apple iOS and Windows to choose UI patterns users are already
acquainted with.

6. Its Performance vs Battery Life: Besides, design and interaction, app


performance and battery consumption are also important aspects of mobile
app development. The challenge is to design a well-performing, bug-free app
which runs on minimum possible battery. Performance, however, is solely
considered to be a development feature and hence dealt with late during the
design phase. Plus, different users perceive app performance differently. And
then there are the devices. The app might function well on the latest device,
but a lot of users are still running on older devices. Too many images or
visual effects, flooding the cache, or using integrated sensors may disrupt
the performance of your application on older versions.

Solution: Make sure the development team is a part of the prototyping


efforts. Besides, set up a beta version to run test cases with test users to
avoid any performance trouble in the final version.

7. Mobile Content Management: The need for mobile app content is ever
growing. The call of the hour is to include rich content videos, images,
animations etc. However, the performance fails of wireless networks and
frequent connection drops make it difficult to deliver reliable yet rich content
that consumes a lot of bandwidth. Besides, app stores like Google Play
require you to bundle all your rich content into monolithic expansion files.
This means whenever you want to update your content, you need to release
a new version of the app.

Solution: Mobile content management solutions. There are various systems


in the market which aim at simplifying content management for mobiles.
They help in optimizing bandwidth usage and delivering content
reliably. Alfresco, MobileIron and AirWatch are some examples.

8. Connecting with the user: The mobile app market is changing rapidly.
Innovation and creativity have made this ecosystem highly active. Thus
connecting with the users is crucial. And no, it is not just about the features
you include in the app.

Solution: Make a positive first impression. This is essential to all


relationships. The key is to make your users feel comfortable. Think beyond
user-friendly design and interactive features. Give them a recognizable
design, colors and logos etched in their memories, or typical fonts. You may
even look at your competitors app not to copy the design or flow, but to
see what users find interesting and create something unique on the same
lines. Besides, it is important to be there for the users always. Listen to their
feedback, pay attention to the smallest issues, thank the ones who find
them, and provide immediate help. This is the key to winning happy and
loyal users.

9. Promoting and Marketing the App: Its a clich that most developers
dont care about marketing their apps. However, its not true. There are
several challenges which developers face while taking their apps to the
market. The bottleneck competition, tight timelines and lack of right
platforms push developers into keeping app marketing on the back burner.

Solution: A successful app is about 90% marketing and 10% development.


So look for the right tools and platforms which can simplify marketing for
you. AppTamin, AppScend , MobileDevHQ, and Smore are some tools you
must check out. Besides, you can take help from professionals, some who
has the required experience and expertise in marketing mobile apps.

10. Lack of Transparency by App Stores: How your app will fare depends
partially on the app store you are submitting it to. However, app stores arent
100% transparent. There is no way of knowing the market size for different
categories or which category is trending globally. In other words, is there a
market for the app you are developing? If yes, where is it? Without knowing
such basic facts you can only depend on your gut instincts to market the
app.

Solution: The only way out is to research. Go through the reports released
by various app stores. Based on the data you can get an estimate of where
and why your app is most likely to sell.
Software and system requirement specification (Development)

Hardware and Software Requirements

The hardware and software requirements for building apps in Android


Studio vary depending on your operating system and the mobile platforms
for which you are developing.

Windows-Based Requirements

Computers running Microsoft Windows must meet the following minimal


hardware and software requirements.

Dual-core 64-bit processor

8 GB of memory

Up to 24 GB of internal storage ( Android SDK: 4GB, plus ample space


for multiple complex projects)

Network interface card

Windows 10, Windows 8.1 Update, Windows 8, and Windows 7.

Mac-Based Requirements

Apple computers must meet the following minimal hardware and software
requirements.

x86-64 processor (64-bit Mac with an Intel Core 2 Duo, Intel Core i3,
Intel Core i5, Intel Core i7, or Xeon processor)

8 GB of memory

150 GB of internal storage

Network interface card

Mac OS X version 10.7 and above


Java SE 7 runtime (Required by Eclipse. You are prompted to install Java
SE 7 runtime the first time you launch Android Studio.)

Additional Requirements by Platform

Along with those previously listed, each development platform has additional
requirements. Detailed information on how to meet these requirements is
provided in the procedures for installing each platform's respective software
development kit (SDK) and emulator.

iOS

Developing apps for iOS includes the following requirements.

iOS-related code and applications can only be developed on a Mac OS


computer

The latest version of Xcode, the Apple SDK for creating iOS apps

Android

Developing apps for Android includes the following requirements.

The Android SDK

Apache Ant (Another Neat Tool), an open-source tool that automates


aspects of the Android build process.

Gradle (An advanced build toolkit that manages dependencies and


allows to define custom build logic.)

Windows Mobile

Developing apps for Windows Mobile includes the following requirements.

For Windows 8.1 mobile devices

Processor that supports Second Level Address Translation (SLAT)

Windows 8 Pro edition with the 8.1 update

6.5 GB of internal storage


8 GB memory

Windows Phone SDK 8.0

Visual Studio Express 2013 for Windows

Windows Phone 8.1 Update 1 Emulators

For Windows 8.0 Mobile Devices

Processor that supports Second Level Address Translation (SLAT)

Windows 8 Pro edition or greater

8 GB of internal storage

4 GB memory

Windows Phone SDK 8.0

Visual Studio Express 2013 for Windows

BlackBerry

Developing apps for BlackBerry includes the following requirements.

VMware Player, used for device emulation.

BlackBerry Native SDK (the version varies depending on what version


of BlackBerry device you want your app to support).

System Requirement

Robust and flexible build system ... System Requirements ... IDE + 1.5 GB for
Android SDK and emulator system image); 1280 x 800 minimum screen
resolution.

You can choose which version of the Android system you want to run in the ... SDK
Tools 25.0.10 or higher; System requirements for the accelerated emulator.
5-System Design and Algorithm

System Design
Algorithm
Step 1. Application START.

Step 2. On Device Bluetooth.

Step 3. Chat window appear.

Step 4. Select device to connect.

Step 5. Click Menu & Select Option.

Step 6. Type on EditText portion.

Step 7. Click Send.

Step 8. Application STOP.


Bluetooth Chat App DFD

Bluetooth
Chat
App
Open

User Message Send

0 Level DFD..

Message Delivered

Open Connected
Bluetooth Enter Text
User On/Off

Not Not-Connected
1 Level DFD

6-Coding and forms


Java coding
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.mcn.bluetoothchat.services;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.mcn.bluetoothchat.utils.Constants;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;

/**
* Created by .on 30/3/17.
*/
public class BluetoothChatService {
// Debugging
private static final String TAG = "BluetoothChatService";

// Name for the SDP record when creating server socket


private static final String NAME_SECURE = "BluetoothChatSecure";
private static final String NAME_INSECURE = "BluetoothChatInsecure";

// Unique UUID for this application


private static final UUID MY_UUID_SECURE =
UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
private static final UUID MY_UUID_INSECURE =
UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");

// Member fields
private final BluetoothAdapter mAdapter;
private final Handler mHandler;
private AcceptThread mSecureAcceptThread;
private AcceptThread mInsecureAcceptThread;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
private int mState;
private int mNewState;

// Constants that indicate the current connection state


public static final int STATE_NONE = 0; // we're doing nothing
public static final int STATE_LISTEN = 1; // now listening for incoming connections
public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
public static final int STATE_CONNECTED = 3; // now connected to a remote device

/**
* Constructor. Prepares a new BluetoothChat session.
*
* @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
*/
public BluetoothChatService(Context context, Handler handler) {
mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
mNewState = mState;
mHandler = handler;
}

/**
* Update UI title according to the current state of the chat connection
*/
private synchronized void updateUserInterfaceTitle() {
mState = getState();
mNewState = mState;

// Give the new state to the Handler so the UI Activity can update
mHandler.obtainMessage(Constants.MESSAGE_STATE_CHANGE, mNewState,
-1).sendToTarget();
}

/**
* Return the current connection state.
*/
public synchronized int getState() {
return mState;
}

/**
* Start the chat service. Specifically start AcceptThread to begin a
* session in listening (server) mode. Called by the Activity onResume()
*/
public synchronized void start() {

// Cancel any thread attempting to make a connection


if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Start the thread to listen on a BluetoothServerSocket


if (mSecureAcceptThread == null) {
mSecureAcceptThread = new AcceptThread(true);
mSecureAcceptThread.start();
}
if (mInsecureAcceptThread == null) {
mInsecureAcceptThread = new AcceptThread(false);
mInsecureAcceptThread.start();
}
// Update UI title
updateUserInterfaceTitle();
}

/**
* Start the ConnectThread to initiate a connection to a remote device.
*
* @param device The BluetoothDevice to connect
* @param secure Socket Security type - Secure (true) , Insecure (false)
*/
public synchronized void connect(BluetoothDevice device, boolean secure) {

// Cancel any thread attempting to make a connection


if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Start the thread to connect with the given device


mConnectThread = new ConnectThread(device, secure);
mConnectThread.start();
// Update UI title
updateUserInterfaceTitle();
}

/**
* Start the ConnectedThread to begin managing a Bluetooth connection
*
* @param socket The BluetoothSocket on which the connection was made
* @param device The BluetoothDevice that has been connected
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
device, final String socketType) {

// Cancel the thread that completed the connection


if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Cancel the accept thread because we only want to connect to one device
if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}
if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}

// Start the thread to manage the connection and perform transmissions


mConnectedThread = new ConnectedThread(socket, socketType);
mConnectedThread.start();

// Send the name of the connected device back to the UI Activity


Message msg = mHandler.obtainMessage(Constants.MESSAGE_DEVICE_NAME);
Bundle bundle = new Bundle();
bundle.putString(Constants.DEVICE_NAME, device.getName());
msg.setData(bundle);
mHandler.sendMessage(msg);
// Update UI title
updateUserInterfaceTitle();
}

/**
* Stop all threads
*/
public synchronized void stop() {

if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}

if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}
mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();
}

/**
* Write to the ConnectedThread in an unsynchronized manner
*
* @param out The bytes to write
* @see ConnectedThread#write(byte[])
*/
public void write(byte[] out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
// Perform the write unsynchronized
r.write(out);
}

/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Constants.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);

mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();

// Start the service over to restart listening mode


BluetoothChatService.this.start();
}

/**
* Indicate that the connection was lost and notify the UI Activity.
*/
private void connectionLost() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Constants.TOAST, "Device connection was lost");
msg.setData(bundle);
mHandler.sendMessage(msg);

mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();

// Start the service over to restart listening mode


BluetoothChatService.this.start();
}

/**
* This thread runs while listening for incoming connections. It behaves
* like a server-side client. It runs until a connection is accepted
* (or until cancelled).
*/
private class AcceptThread extends Thread {
// The local server socket
private final BluetoothServerSocket mmServerSocket;
private String mSocketType;
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";

// Create a new listening server socket


try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {

}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}

public void run() {


setName("AcceptThread" + mSocketType);

BluetoothSocket socket = null;

// Listen to the server socket if we're not connected


while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
break;
}

// If a connection was accepted


if (socket != null) {
synchronized (BluetoothChatService.this) {
switch (mState) {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
connected(socket, socket.getRemoteDevice(),
mSocketType);
break;
case STATE_NONE:
case STATE_CONNECTED:
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) {
}
break;
}
}
}
}

public void cancel() {


try {
mmServerSocket.close();
} catch (IOException e) {

}
}
}

/**
* This thread runs while attempting to make an outgoing connection
* with a device. It runs straight through; the connection either
* succeeds or fails.
*/
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private String mSocketType;

public ConnectThread(BluetoothDevice device, boolean secure) {


mmDevice = device;
BluetoothSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";

// Get a BluetoothSocket for a connection with the


// given BluetoothDevice
try {
if (secure) {
tmp = device.createRfcommSocketToServiceRecord(
MY_UUID_SECURE);
} else {
tmp = device.createInsecureRfcommSocketToServiceRecord(
MY_UUID_INSECURE);
}
} catch (IOException e) {
e.printStackTrace();
}
mmSocket = tmp;
mState = STATE_CONNECTING;
}

public void run() {


setName("ConnectThread" + mSocketType);

// Always cancel discovery because it will slow down a connection


mAdapter.cancelDiscovery();

// Make a connection to the BluetoothSocket


try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
e2.printStackTrace();
}
connectionFailed();
return;
}

// Reset the ConnectThread because we're done


synchronized (BluetoothChatService.this) {
mConnectThread = null;
}

// Start the connected thread


connected(mmSocket, mmDevice, mSocketType);
}

public void cancel() {


try {
mmSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

/**
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;

public ConnectedThread(BluetoothSocket socket, String socketType) {


mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;

// Get the BluetoothSocket input and output streams


try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
}

mmInStream = tmpIn;
mmOutStream = tmpOut;
mState = STATE_CONNECTED;
}

public void run() {


byte[] buffer = new byte[1024];
int bytes;

// Keep listening to the InputStream while connected


while (mState == STATE_CONNECTED) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);

// Send the obtained bytes to the UI Activity


mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
connectionLost();
break;
}
}
}

/**
* Write to the connected OutStream.
*
* @param buffer The bytes to write
*/
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);

// Share the sent message back to the UI Activity


mHandler.obtainMessage(Constants.MESSAGE_WRITE, -1, -1, buffer)
.sendToTarget();
} catch (IOException e) {
}
}

public void cancel() {


try {
mmSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

package com.mcn.bluetoothchat.activity;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.mcn.bluetoothchat.R;

import java.util.Set;

/**
* Created by amit on 30/3/17.
*/

public class DeviceListActivity extends AppCompatActivity {


/**
* Tag for Log
*/
private static final String TAG = "DeviceListActivity";

/**
* Return Intent extra
*/
public static String EXTRA_DEVICE_ADDRESS = "device_address";

/**
* Member fields
*/
private BluetoothAdapter mBtAdapter;

/**
* Newly discovered devices
*/
private ArrayAdapter<String> mNewDevicesArrayAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Setup the window


requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_device_list);

// Set result CANCELED in case the user backs out


setResult(Activity.RESULT_CANCELED);
// Initialize the button to perform device discovery
Button scanButton = (Button) findViewById(R.id.button_scan);
scanButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
doDiscovery();
v.setVisibility(View.GONE);
}
});

// Initialize array adapters. One for already paired devices and


// one for newly discovered devices
ArrayAdapter<String> pairedDevicesArrayAdapter =
new ArrayAdapter<String>(this, R.layout.device_name);
mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);

// Find and set up the ListView for paired devices


ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
pairedListView.setAdapter(pairedDevicesArrayAdapter);
pairedListView.setOnItemClickListener(mDeviceClickListener);

// Find and set up the ListView for newly discovered devices


ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
newDevicesListView.setOnItemClickListener(mDeviceClickListener);

// Register for broadcasts when a device is discovered


IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);

// Register for broadcasts when discovery has finished


filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);

// Get the local Bluetooth adapter


mBtAdapter = BluetoothAdapter.getDefaultAdapter();

// Get a set of currently paired devices


Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();

// If there are paired devices, add each one to the ArrayAdapter


if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
for (BluetoothDevice device : pairedDevices) {
pairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
} else {
String noDevices = getResources().getText(R.string.none_paired).toString();
pairedDevicesArrayAdapter.add(noDevices);
}
}

@Override
protected void onDestroy() {
super.onDestroy();

// Make sure we're not doing discovery anymore


if (mBtAdapter != null) {
mBtAdapter.cancelDiscovery();
}

// Unregister broadcast listeners


this.unregisterReceiver(mReceiver);
}

/**
* Start device discover with the BluetoothAdapter
*/
private void doDiscovery() {

// Indicate scanning in the title


setProgressBarIndeterminateVisibility(true);
setTitle(R.string.scanning);

// Turn on sub-title for new devices


findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);

// If we're already discovering, stop it


if (mBtAdapter.isDiscovering()) {
mBtAdapter.cancelDiscovery();
}

// Request discover from BluetoothAdapter


mBtAdapter.startDiscovery();
}

/**
* The on-click listener for all devices in the ListViews
*/
private AdapterView.OnItemClickListener mDeviceClickListener
= new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
// Cancel discovery because it's costly and we're about to connect
mBtAdapter.cancelDiscovery();

// Get the device MAC address, which is the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);

// Create the result Intent and include the MAC address


Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);

// Set result and finish this Activity


setResult(Activity.RESULT_OK, intent);
finish();
}
};

/**
* The BroadcastReceiver that listens for discovered devices and changes the title when
* discovery is finished
*/
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

// When discovery finds a device


if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device =
intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
setProgressBarIndeterminateVisibility(false);
setTitle(R.string.select_device);
if (mNewDevicesArrayAdapter.getCount() == 0) {
String noDevices = getResources().getText(R.string.none_found).toString();
mNewDevicesArrayAdapter.add(noDevices);
}
}
}
};
}
package com.mcn.bluetoothchat.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.mcn.bluetoothchat.R;
import com.mcn.bluetoothchat.model.ChatMessage;

import java.util.ArrayList;
import java.util.List;

/**
* Created by amit on 30/3/17.
*/

public class ChatArrayAdapter extends ArrayAdapter<ChatMessage> {

private TextView chatText;


private List<ChatMessage> chatMessageList = new ArrayList<ChatMessage>();
private Context context;

@Override
public void add(ChatMessage object) {
chatMessageList.add(object);
super.add(object);
}

public ChatArrayAdapter(Context context, int textViewResourceId) {


super(context, textViewResourceId);
this.context = context;
}

public int getCount() {


return this.chatMessageList.size();
}

public ChatMessage getItem(int index) {


return this.chatMessageList.get(index);
}

public View getView(int position, View convertView, ViewGroup parent) {


ChatMessage chatMessageObj = getItem(position);
/* View row = convertView;
LayoutInflater inflater = (LayoutInflater)
this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (chatMessageObj.left) {
row = inflater.inflate(R.layout.right, parent, false);
}else{
row = inflater.inflate(R.layout.left, parent, false);
}
chatText = (TextView) row.findViewById(R.id.msgr);
chatText.setText(chatMessageObj.message);*/
return null;
}
}

package com.mcn.bluetoothchat.model;

/**
* Created by amit on 30/3/17.
*/

public class ChatMessage {


public String message;
public boolean isMine;

public String getMessage() {


return message;
}

public void setMessage(String message) {


this.message = message;
}

public boolean isMine() {


return isMine;
}

public void setMine(boolean mine) {


isMine = mine;
}
}
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.mcn.bluetoothchat.services;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.mcn.bluetoothchat.utils.Constants;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;

/**
* Created by amit on 30/3/17.
*/
public class BluetoothChatService {
// Debugging
private static final String TAG = "BluetoothChatService";

// Name for the SDP record when creating server socket


private static final String NAME_SECURE = "BluetoothChatSecure";
private static final String NAME_INSECURE = "BluetoothChatInsecure";

// Unique UUID for this application


private static final UUID MY_UUID_SECURE =
UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
private static final UUID MY_UUID_INSECURE =
UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");

// Member fields
private final BluetoothAdapter mAdapter;
private final Handler mHandler;
private AcceptThread mSecureAcceptThread;
private AcceptThread mInsecureAcceptThread;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
private int mState;
private int mNewState;

// Constants that indicate the current connection state


public static final int STATE_NONE = 0; // we're doing nothing
public static final int STATE_LISTEN = 1; // now listening for incoming connections
public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
public static final int STATE_CONNECTED = 3; // now connected to a remote device

/**
* Constructor. Prepares a new BluetoothChat session.
*
* @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
*/
public BluetoothChatService(Context context, Handler handler) {
mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
mNewState = mState;
mHandler = handler;
}

/**
* Update UI title according to the current state of the chat connection
*/
private synchronized void updateUserInterfaceTitle() {
mState = getState();
mNewState = mState;

// Give the new state to the Handler so the UI Activity can update
mHandler.obtainMessage(Constants.MESSAGE_STATE_CHANGE, mNewState,
-1).sendToTarget();
}
/**
* Return the current connection state.
*/
public synchronized int getState() {
return mState;
}

/**
* Start the chat service. Specifically start AcceptThread to begin a
* session in listening (server) mode. Called by the Activity onResume()
*/
public synchronized void start() {

// Cancel any thread attempting to make a connection


if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Start the thread to listen on a BluetoothServerSocket


if (mSecureAcceptThread == null) {
mSecureAcceptThread = new AcceptThread(true);
mSecureAcceptThread.start();
}
if (mInsecureAcceptThread == null) {
mInsecureAcceptThread = new AcceptThread(false);
mInsecureAcceptThread.start();
}
// Update UI title
updateUserInterfaceTitle();
}

/**
* Start the ConnectThread to initiate a connection to a remote device.
*
* @param device The BluetoothDevice to connect
* @param secure Socket Security type - Secure (true) , Insecure (false)
*/
public synchronized void connect(BluetoothDevice device, boolean secure) {
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Start the thread to connect with the given device


mConnectThread = new ConnectThread(device, secure);
mConnectThread.start();
// Update UI title
updateUserInterfaceTitle();
}

/**
* Start the ConnectedThread to begin managing a Bluetooth connection
*
* @param socket The BluetoothSocket on which the connection was made
* @param device The BluetoothDevice that has been connected
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
device, final String socketType) {

// Cancel the thread that completed the connection


if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

// Cancel any thread currently running a connection


if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

// Cancel the accept thread because we only want to connect to one device
if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}
if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}

// Start the thread to manage the connection and perform transmissions


mConnectedThread = new ConnectedThread(socket, socketType);
mConnectedThread.start();

// Send the name of the connected device back to the UI Activity


Message msg = mHandler.obtainMessage(Constants.MESSAGE_DEVICE_NAME);
Bundle bundle = new Bundle();
bundle.putString(Constants.DEVICE_NAME, device.getName());
msg.setData(bundle);
mHandler.sendMessage(msg);
// Update UI title
updateUserInterfaceTitle();
}

/**
* Stop all threads
*/
public synchronized void stop() {

if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}

if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}

if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}

if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}
mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();
}

/**
* Write to the ConnectedThread in an unsynchronized manner
*
* @param out The bytes to write
* @see ConnectedThread#write(byte[])
*/
public void write(byte[] out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
// Perform the write unsynchronized
r.write(out);
}

/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Constants.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);

mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();

// Start the service over to restart listening mode


BluetoothChatService.this.start();
}

/**
* Indicate that the connection was lost and notify the UI Activity.
*/
private void connectionLost() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Constants.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Constants.TOAST, "Device connection was lost");
msg.setData(bundle);
mHandler.sendMessage(msg);

mState = STATE_NONE;
// Update UI title
updateUserInterfaceTitle();

// Start the service over to restart listening mode


BluetoothChatService.this.start();
}

/**
* This thread runs while listening for incoming connections. It behaves
* like a server-side client. It runs until a connection is accepted
* (or until cancelled).
*/
private class AcceptThread extends Thread {
// The local server socket
private final BluetoothServerSocket mmServerSocket;
private String mSocketType;

public AcceptThread(boolean secure) {


BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";

// Create a new listening server socket


try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {

}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}

public void run() {


setName("AcceptThread" + mSocketType);
BluetoothSocket socket = null;

// Listen to the server socket if we're not connected


while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
break;
}

// If a connection was accepted


if (socket != null) {
synchronized (BluetoothChatService.this) {
switch (mState) {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
connected(socket, socket.getRemoteDevice(),
mSocketType);
break;
case STATE_NONE:
case STATE_CONNECTED:
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) {
}
break;
}
}
}
}

public void cancel() {


try {
mmServerSocket.close();
} catch (IOException e) {

}
}
}
/**
* This thread runs while attempting to make an outgoing connection
* with a device. It runs straight through; the connection either
* succeeds or fails.
*/
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private String mSocketType;

public ConnectThread(BluetoothDevice device, boolean secure) {


mmDevice = device;
BluetoothSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";

// Get a BluetoothSocket for a connection with the


// given BluetoothDevice
try {
if (secure) {
tmp = device.createRfcommSocketToServiceRecord(
MY_UUID_SECURE);
} else {
tmp = device.createInsecureRfcommSocketToServiceRecord(
MY_UUID_INSECURE);
}
} catch (IOException e) {
e.printStackTrace();
}
mmSocket = tmp;
mState = STATE_CONNECTING;
}

public void run() {


setName("ConnectThread" + mSocketType);

// Always cancel discovery because it will slow down a connection


mAdapter.cancelDiscovery();

// Make a connection to the BluetoothSocket


try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
e2.printStackTrace();
}
connectionFailed();
return;
}

// Reset the ConnectThread because we're done


synchronized (BluetoothChatService.this) {
mConnectThread = null;
}

// Start the connected thread


connected(mmSocket, mmDevice, mSocketType);
}

public void cancel() {


try {
mmSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

/**
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;

public ConnectedThread(BluetoothSocket socket, String socketType) {


mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;

// Get the BluetoothSocket input and output streams


try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
}

mmInStream = tmpIn;
mmOutStream = tmpOut;
mState = STATE_CONNECTED;
}

public void run() {


byte[] buffer = new byte[1024];
int bytes;

// Keep listening to the InputStream while connected


while (mState == STATE_CONNECTED) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);

// Send the obtained bytes to the UI Activity


mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
connectionLost();
break;
}
}
}

/**
* Write to the connected OutStream.
*
* @param buffer The bytes to write
*/
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);

// Share the sent message back to the UI Activity


mHandler.obtainMessage(Constants.MESSAGE_WRITE, -1, -1, buffer)
.sendToTarget();
} catch (IOException e) {
}
}

public void cancel() {


try {
mmSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.mcn.bluetoothchat.utils;

import com.mcn.bluetoothchat.services.BluetoothChatService;

/**
* Defines several constants used between {@link BluetoothChatService} and the UI.
*/
public interface Constants {

// Message types sent from the BluetoothChatService Handler


public static final int MESSAGE_STATE_CHANGE = 1;
public static final int MESSAGE_READ = 2;
public static final int MESSAGE_WRITE = 3;
public static final int MESSAGE_DEVICE_NAME = 4;
public static final int MESSAGE_TOAST = 5;

// Key names received from the BluetoothChatService Handler


public static final String DEVICE_NAME = "device_name";
public static final String TOAST = "toast";

}
package com.mcn.bluetoothchat;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.mcn.bluetoothchat.activity.DeviceListActivity;
import com.mcn.bluetoothchat.services.BluetoothChatService;
import com.mcn.bluetoothchat.utils.Constants;

public class MainActivity extends AppCompatActivity {

// Intent request codes


private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
private static final int REQUEST_ENABLE_BT = 3;

// Layout Views
private ListView mConversationView;
private EditText mOutEditText;
private Button mSendButton;

/**
* Name of the connected device
*/
private String mConnectedDeviceName = null;
/**
* Array adapter for the conversation thread
*/
private ArrayAdapter<String> mConversationArrayAdapter;

/**
* String buffer for outgoing messages
*/
private StringBuffer mOutStringBuffer;

/**
* Local Bluetooth adapter
*/
private BluetoothAdapter mBluetoothAdapter = null;

/**
* Member object for the chat services
*/
private BluetoothChatService mChatService = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

// If the adapter is null, then Bluetooth is not supported


if (mBluetoothAdapter == null) {
Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
finish();
}

mConversationView = (ListView) findViewById(R.id.in);


mOutEditText = (EditText) findViewById(R.id.edit_text_out);
mSendButton = (Button) findViewById(R.id.button_send);
}

@Override
protected void onStart() {
super.onStart();
if (!mBluetoothAdapter.isEnabled()) {
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
// Otherwise, setup the chat session
} else if (mChatService == null) {
setupChat();
}
}

@Override
public void onDestroy() {
super.onDestroy();
if (mChatService != null) {
mChatService.stop();
}
}

@Override
public void onResume() {
super.onResume();
if (mChatService != null) {
// Only if the state is STATE_NONE, do we know that we haven't started already
if (mChatService.getState() == BluetoothChatService.STATE_NONE) {
// Start the Bluetooth chat services
mChatService.start();
}
}
}

/**
* Set up the UI and background operations for chat.
*/
private void setupChat() {
// Initialize the array adapter for the conversation thread
mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);

mConversationView.setAdapter(mConversationArrayAdapter);

// Initialize the compose field with a listener for the return key
mOutEditText.setOnEditorActionListener(mWriteListener);

// Initialize the send button with a listener that for click events
mSendButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Send a message using content of the edit text widget

String message = mOutEditText.getText().toString();


sendMessage(message);

}
});
// Initialize the BluetoothChatService to perform bluetooth connections
mChatService = new BluetoothChatService(this, mHandler);

// Initialize the buffer for outgoing messages


mOutStringBuffer = new StringBuffer("");
}

/**
* Makes this device discoverable for 300 seconds (5 minutes).
*/
private void ensureDiscoverable() {
if (mBluetoothAdapter.getScanMode() !=
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
Intent discoverableIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);

discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
}
}

/**
* Sends a message.
*
* @param message A string of text to send.
*/
private void sendMessage(String message) {
// Check that we're actually connected before trying anything
if (mChatService.getState() != BluetoothChatService.STATE_CONNECTED) {
Toast.makeText(this, getString(R.string.not_connected),
Toast.LENGTH_SHORT).show();
return;
}

// Check that there's actually something to send


if (message.length() > 0) {
// Get the message bytes and tell the BluetoothChatService to write
byte[] send = message.getBytes();
mChatService.write(send);

// Reset out string buffer to zero and clear the edit text field
mOutStringBuffer.setLength(0);
mOutEditText.setText(mOutStringBuffer);
}
}
/**
* The action listener for the EditText widget, to listen for the return key
*/
private TextView.OnEditorActionListener mWriteListener
= new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
// If the action is a key-up event on the return key, send the message
if (actionId == EditorInfo.IME_NULL && event.getAction() ==
KeyEvent.ACTION_UP) {
String message = view.getText().toString();
sendMessage(message);
}
return true;
}
};

/**
* Updates the status on the action bar.
*
* @param resId a string resource ID
*/
private void setStatus(int resId) {

final ActionBar actionBar = getSupportActionBar();


if (null == actionBar) {
return;
}
actionBar.setSubtitle(resId);
}

/**
* Updates the status on the action bar.
*
* @param subTitle status
*/
private void setStatus(CharSequence subTitle) {

final ActionBar actionBar = getSupportActionBar();


if (null == actionBar) {
return;
}
actionBar.setSubtitle(subTitle);
}

/**
* The Handler that gets information back from the BluetoothChatService
*/
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case Constants.MESSAGE_STATE_CHANGE:
switch (msg.arg1) {
case BluetoothChatService.STATE_CONNECTED:
setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
mConversationArrayAdapter.clear();
break;
case BluetoothChatService.STATE_CONNECTING:
setStatus(R.string.title_connecting);
break;
case BluetoothChatService.STATE_LISTEN:
case BluetoothChatService.STATE_NONE:
setStatus(R.string.title_not_connected);
break;
}
break;
case Constants.MESSAGE_WRITE:
byte[] writeBuf = (byte[]) msg.obj;
// construct a string from the buffer
String writeMessage = new String(writeBuf);
mConversationArrayAdapter.add("Me: " + writeMessage);
break;
case Constants.MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
// construct a string from the valid bytes in the buffer
String readMessage = new String(readBuf, 0, msg.arg1);
mConversationArrayAdapter.add(mConnectedDeviceName + ": " +
readMessage);
break;
case Constants.MESSAGE_DEVICE_NAME:
// save the connected device's name
mConnectedDeviceName = msg.getData().getString(Constants.DEVICE_NAME);

Toast.makeText(MainActivity.this, "Connected to "


+ mConnectedDeviceName, Toast.LENGTH_SHORT).show();

break;
case Constants.MESSAGE_TOAST:

Toast.makeText(MainActivity.this, msg.getData().getString(Constants.TOAST),
Toast.LENGTH_SHORT).show();
break;
}
}
};

public void onActivityResult(int requestCode, int resultCode, Intent data) {


switch (requestCode) {
case REQUEST_CONNECT_DEVICE_SECURE:
// When DeviceListActivity returns with a device to connect
if (resultCode == Activity.RESULT_OK) {
connectDevice(data, true);
}
break;
case REQUEST_CONNECT_DEVICE_INSECURE:
// When DeviceListActivity returns with a device to connect
if (resultCode == Activity.RESULT_OK) {
connectDevice(data, false);
}
break;
case REQUEST_ENABLE_BT:
// When the request to enable Bluetooth returns
if (resultCode == Activity.RESULT_OK) {
// Bluetooth is now enabled, so set up a chat session
setupChat();
} else {
// User did not enable Bluetooth or an error occurred

Toast.makeText(this, R.string.bt_not_enabled_leaving,
Toast.LENGTH_SHORT).show();
finish();
}
}
}

/**
* Establish connection with other device
*
* @param data An {@link Intent} with {@link
DeviceListActivity#EXTRA_DEVICE_ADDRESS} extra.
* @param secure Socket Security type - Secure (true) , Insecure (false)
*/
private void connectDevice(Intent data, boolean secure) {
// Get the device MAC address
String address = data.getExtras()
.getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
// Get the BluetoothDevice object
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
// Attempt to connect to the device
mChatService.connect(device, secure);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bluetooth_chat, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.secure_connect_scan: {
// Launch the DeviceListActivity to see devices and do scan
Intent serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
return true;
}
case R.id.insecure_connect_scan: {
// Launch the DeviceListActivity to see devices and do scan
Intent serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE);
return true;
}
case R.id.discoverable: {
// Ensure this device is discoverable by others
ensureDiscoverable();
return true;
}
}
return false;
}

package com.mcn.bluetoothchat;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.mcn.bluetoothchat", appContext.getPackageName());
}
}

package com.mcn.bluetoothchat;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

xml coding
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/title_paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#666"
android:paddingLeft="5dp"
android:text="@string/title_paired_devices"
android:textColor="#fff"
android:visibility="gone" />

<ListView
android:id="@+id/paired_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:stackFromBottom="true" />

<TextView
android:id="@+id/title_new_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#666"
android:paddingLeft="5dp"
android:text="@string/title_other_devices"
android:textColor="#fff"
android:visibility="gone" />

<ListView
android:id="@+id/new_devices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:stackFromBottom="true" />

<Button
android:id="@+id/button_scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_scan" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ListView
android:id="@+id/in"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:stackFromBottom="true"
android:dividerHeight="0dp"
android:transcriptMode="alwaysScroll" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<EditText
android:id="@+id/edit_text_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1" />

<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send" />
</LinearLayout>

</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>


<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="18sp" />

<?xml version="1.0" encoding="utf-8"?>


<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="18sp" />

<?xml version="1.0" encoding="utf-8"?>


<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

<resources>

<!-- Base application theme. -->


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

<resources>

<!-- Base application theme. -->


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.mcn.bluetoothchat"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
7-Testing and Implementation
SOFTWARE TESTING

Software Testing is a critical element of Software Quality Assurance (SQA)


and represents the ultimate review of specification, design and coding. The
engineer creates a series of tests cases that are intended to demolish the
software that has been built. In fact testing is the one step in the software
engineering process that could be reviewed as destructive rather then
constructive.

Testing Objectives:-

Glen Myers states testing objectives as: -

Testing is the process of executing a program with the intend of finding an


error.
A good test case is one that has a high probability of finding an as yet
uncovered error.
A successful test is one that uncovers an as yet uncovered error If the
testing is conducted successfully it will uncover errors in the software.
As a secondary benefit, testing demonstrates that software function to be
working according to specification that performance required appears to
have been met.
A strategy for Software Testing integrates software test case design
techniques into well-planned steps that result in the successful
construction of software.
A software testing strategy has the following generic characteristic: -

Testing begins at the module level and works outward towards the
integration of the entire computer based system.
Different testing techniques are appropriate at different point of time.
Testing is conducted by the developer of the software and independent
test group (ITG).
Testing and debugging are different activities, but debugging must be
accommodated in any testing strategy.

The software testing strategy followed: -

Unit testing begins at the vortex of the spiral and concentrate on each unit of
the software as implemented in the source code. As we know that initially
test focus on each module individually, ensuring that it function properly as a
unit. It makes heavy use of white box Testing.
Integration testing where the focus is on the design and construction of the
software architecture.

Validation testing where the requirement established as part of software


requirement analysis is validated against that has been constructed.

System tests where the software and other system element are tested as a
whole.

Debugging

Out of the three categories of debugging approach namely Brute force,


Backtracking and Cause elimination we have used Backtracking.

Backtracking is a fair common debugging approach that can be used


successfully in small programs. Beginning at the site where a symptom been
uncovered, the source is traced backward (manually) until the site of the
cause is found.

8-Conclusions, Limitation and Future Scope

This app allows you to create your own chat room that people around can
join in via Bluetooth connection. Bluetooth chat is a messaging application
that uses Bluetooth as the connection method, Bluetooth does not require
Internet connection, and this method of messaging has no cost.
It gives simple approaches to deal with the Bluetooth connector of the
nearby gadget and to send control keys, interchange keys, capacity keys and
other uncommon keys.

Don't have an internet connection nearby! No Problem! Chat with your


friends with the Free Best Chatting Android App through Bluetooth over short
distance!

In future, it is possible to add more fields for notifications and extend scope
to the whole country.

This application is useful to the android users. Officials as well as general


public can use the application. Data Flow diagram for Bluetooth Chat
Application is as follows which shows interfacing details of Bluetooth Chat
Application.

9-References

Android Tutorial

Sites https://developer.android.com/develop/index.html

http://www.vogella.com/tutorials/android.html

10-Appendix

A.Approval sheet, Aknowledgement ,About the cogining.


B. Blackberry, Bluetooth chatting app.
C. Certificate, Company profile, Coading, Conclusions.
D. Declaration, Disadvantage of android studio.
E. _________
F. Fixed cost project, Forms, Future scope.
G. Getting the app funded.
H. Hardware fragmentation.
I. Introduction, implementation.
J. Java coading.
K. Keeping it simple and clear.
L. Latest and cutting edge, Limitations.
M. Market research costs.
N. _______
O. On device Bluetooth.
P. Patent issues, Problem statement.
Q. ________
R. Requirment analyses, Refrences.
S. Software fragmentation, Security, Several corries, System requirement,
System design and algorithm.
T. Table of contents, Technology used, Testing.
U. _______
V. _______
W. Window mobile, window based requirements.
X. Xml coading.
Y. ________
Z. ________