Androble Save

Android library for connecting multiple devices over bluetooth

Project README


Connect nearby devices to your server !

Androble uses Android's Bluetooth API and establishes RFCOMM channels. The server listens for various clients using a unique UUID and the client having the same UUID is connected to the server. In multiple devices, server creates 4 RFCOMM channels with 4 different UUIDs and then each connection is maintained on a different thread by the server so that if anyhow connection with a particular client fails then the connection with other clients is uninterrupted.


Add dependency to build.gradle of your app
compile 'com.mdg.androble:library:0.1.2'


BluetoothManager class is the master class of this library and contains the following functions:

public void Type(String t)

Sets either you want to connect as server or client.

public void scanClients()

Starts scanning clients on server side.

public void connectTo(String s)

Lets client to connect to the desired server from list.

public void sendText(String s)

Allows to send message from client to connected server.

public void sendText(String s,int id)

Allows to send message from server to client specifying the id of client.

public String clientToClient(String s, int id)

Allows to send message from a client to another client specifying the id of recepient client.

public String getAllConnectedDevices()

To fetch list of all connected devices with respective ids.

public void setMessageObject(Object myObject)

Sets the observer object that fetches received messages.

public void setListObject(Object myObject)

Sets the observer object that fetches list of detected devices for client side.

public String disconnect()

To disable your connection.


Extend the activity in which you want to scan for devices by Discovery instead of Activity / AppCompatActivity like:

public class MainActivity extends Discovery{}

then create a class which implements Observer interface. This facilitates receiving of the list of devices scanned by Bluetooth.

class DeviceList implements Observer {
    if(((com.mdg.androble.DeviceList)observable).getContent().equals("bluetooth enabled"))

then create another class, again implementing the Observer interface, for receiving text messages.

class receiveMessage implements Observer {
    public void update(Observable observable, Object data) {
       String msg = ((receivemsg)observable).getMessage();
       //do whatever you want to do with received message

Now get instance of Bluetooth manager class like :

BluetoothManager bluetoothManager= BluetoothManager.getInstance();

now create objects of DeviceList and receiceMessage class like:

receiveMessage  rm = new receiveMessage();
 DeviceList dl=new DeviceList();

pass these objects to setMessageObject and setListObject respectively , like:


Connecting as Server:-

Call Type funtion of BluetoothManager class and pass "SERVER" as parameter:
To send text to any client where id is Id of client:-
bluetoothManager.sendText("your message",playerId)
To get the ID's of all connected devices call getAllConnectedDevices() described above.

Connecting as Client:-

``` bluetoothManager.Type("CLIENT"); ``` //now you will be able to connect to a single server device
``` bluetoothManager.clientToClient("your message",id) ``` where id is the id of connected devices
To get the ID's of all connected devices call ```getAllConnectedDevices()``` described above.

Sample code for MainActivity [Wiki](

App Using This Library


Copyright 2016 Pulkit Karira

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

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
Open Source Agenda is not affiliated with "Androble" Project. README Source: pkarira/Androble
Open Issues
Last Commit
6 years ago

Open Source Agenda Badge

Open Source Agenda Rating