субота, 26. мај 2012.

Wireless chat application using portable WiFi hotspot


Introduction
The Android platform includes support for the wireless network stack, which allows a device to wirelessly exchange data with other devices. The application framework provides access to the wireless functionality through the Android wireless APIs. These APIs let applications connect wirelessly to other devices, enabling point-to-point and multipoint wireless features.

This application allows 2 or more Android devices to communicate without using any external resorces (without Internet at all, also chat servers). What separates this application from the ordinary ones is usage of only tethering.

Depending on your model of Android device and your carrier, you may be able to share your Google™ Android™ device’s mobile data connection with a single computer via a USB cable or via Bluetooth. You may also be able to share your Android device’s data connection with up to five devices at once, by turning your phone into a portable Wi-Fi hotspot.

Establishing connection


   You can turn your Android phone into a portable wi-fi hotspot and get another Android phone to share some information. For this you will need to have Android 2.2 installed on your phone.
The Android  platform introduces many new and exciting features for users and developers.
SHARE YOUR DATA CONNECTION AS A PORTABLE WI-FI HOTSPOT
Open the Settings application.
Touch Wireless & networks > Tethering & portable hotspot.
Check Portable Wi-Fi hotspot.
After a moment, the device starts broadcasting its Wi-Fi network name (SSID), so you can connect to it with up to 8 computers or other devices. An ongoing notification is added to the System bar, to the left of the time.
When Portable Wi-Fi hotspot is checked, you can change its network name or secure it. See Rename or secure your portable hotspot.
Uncheck Portable Wi-Fi hotspot to stop sharing your data connection via Wi-Fi.
Below are setup instruction.



If you want co configure Wi-Fi hotspot,below are next steps





Android chat application

Main goal with this application is making wireless chat communication between android devices.  Application enables tethering (via wifi) for handsets running android. Clients (another android devices) can connect via wifi (ad-hoc mode) and get access from access point, in this case this is android device. When communication is established as described above, application opens a connection and it is possible to send messages between devices.




One device simulates the server side, while another client. To open a connection between devices, you need to make tcp/ip connection using a Socket and ServerSocket in Java.
A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs. The socket associates the server program with a specific hardware port on the machine where it runs so any client program anywhere in the network with a socket associated with that same port can communicate with the server program.
A server program typically provides resources to a network of client programs. Client programs send requests to the server program, and the server program responds to the request.

One way to handle requests from more than one client is to make the server program multi-threaded. A multi-threaded server creates a thread for each communication it accepts from a client. A thread is a sequence of instructions that run independently of the program and of any other threads.
Using threads, a multi-threaded server program can accept a connection from a client, start a thread for that communication, and continue listening for requests from other clients.