• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    Java
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Library for easy implementation of Serial Bluetooth Classic and Low Energy on Android. 💙

AndroidBluetoothLibrary

Licence MIT Release Downloads Android Arsenal

A Library for easy implementation of Serial Bluetooth Classic and Low Energy on Android. 💙

  • Bluetooth Classic working from Android 2.1 (API 7)
  • Bluetooth Low Energy working from Android 4.3 (API 18)

Use

Configuration

Bluetooth Classic

BluetoothConfiguration config = new BluetoothConfiguration();
config.context = getApplicationContext();
config.bluetoothServiceClass = BluetoothClassicService.class;
config.bufferSize = 1024;
config.characterDelimiter = '\n';
config.deviceName = "Your App Name";
config.callListenersInMainThread = true;

config.uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Required

BluetoothService.init(config);

Bluetooth Low Energy

BluetoothConfiguration config = new BluetoothConfiguration();
config.context = getApplicationContext();
config.bluetoothServiceClass = BluetoothLeService.class;
config.bufferSize = 1024;
config.characterDelimiter = '\n';
config.deviceName = "Your App Name";
config.callListenersInMainThread = true;

config.uuidService = UUID.fromString("e7810a71-73ae-499d-8c15-faa9aef0c3f2"); // Required
config.uuidCharacteristic = UUID.fromString("bef8d6c9-9c21-4c9e-b632-bd58c1009f9f"); // Required
config.transport = BluetoothDevice.TRANSPORT_LE; // Required for dual-mode devices
config.uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Used to filter found devices. Set null to find all devices.

BluetoothService.init(config);

Getting BluetoothService

BluetoothService service = BluetoothService.getDefaultInstance();

Scanning

service.setOnScanCallback(new BluetoothService.OnBluetoothScanCallback() {
    @Override
    public void onDeviceDiscovered(BluetoothDevice device, int rssi) {
    }

    @Override
    public void onStartScan() {
    }

    @Override
    public void onStopScan() {
    }
});

service.startScan(); // See also service.stopScan();

Connecting

service.setOnEventCallback(new BluetoothService.OnBluetoothEventCallback() {
    @Override
    public void onDataRead(byte[] buffer, int length) {
    }

    @Override
    public void onStatusChange(BluetoothStatus status) {
    }

    @Override
    public void onDeviceName(String deviceName) {
    }

    @Override
    public void onToast(String message) {
    }

    @Override
    public void onDataWrite(byte[] buffer) {
    }
});

service.connect(device); // See also service.disconnect();

Writing

BluetoothWriter writer = new BluetoothWriter(service);

writer.writeln("Your text here");

Complete example

See the sample project.

Download

  1. Add it in your root build.gradle at the end of repositories:

    allprojects {
      repositories {
        ...
        maven { url "https://jitpack.io" }
      }
    }
  2. Add the dependency

    2.1. Bluetooth Classic

    dependencies {
      implementation 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothClassicLibrary:0.3.5'
    }

    2.2. Bluetooth Low Energy

    dependencies {
      implementation 'com.github.douglasjunior.AndroidBluetoothLibrary:BluetoothLowEnergyLibrary:0.3.5'
    }
  3. Add permission in AndroidManifest.xml

<manifest ...>
  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
  <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  ...
</manifest>

Known Issues / Troubleshooting

  • Scanning will not detect bluetooth devices if the user has denied Location Privacy Permission to your app. This library does not test for the permission and will not raise errors. (Android 6.0+) See: http://stackoverflow.com/a/33045489/2826279

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions use the issues.

Before submit your PR, run the gradle check.

./gradlew build connectedCheck

Become a Patron! Donate

Licence

The MIT License (MIT)

Copyright (c) 2015 Douglas Nassif Roma Junior

See the full licence file.

More Repositories

1

react-native-keyboard-manager

⚛ Library to prevent issues of keyboard sliding up and cover inputs on React-Native iOS projects.
Objective-C
954
star
2

android-simple-tooltip

A simple library based on PopupWindow to create Tooltips on Android. 💚
Java
791
star
3

react-native-simple-dialogs

⚛ Cross-platform React Native dialogs based on the Modal component
TypeScript
323
star
4

react-native-get-location

⚛ Simple to use React Native library to get native device location for Android and iOS.
Java
205
star
5

react-native-recaptcha-that-works

⚛ A reCAPTCHA bridge for React Native that works (Android and iOS)
TypeScript
164
star
6

react-native-pdf-renderer

⚛ A zoomable, blazing fast, zero dependencies, pure native, typed PDF Renderer for Android and iOS.
Java
132
star
7

emage

🧙‍♂️ From developers to developers: a cross-platform tool for losslessly image compression.
JavaScript
120
star
8

react-native-easybluetooth-classic

⚛ A Library for easy implementation of Serial Bluetooth Classic on React Native (Android Only).
Java
43
star
9

react-native-gradient-shimmer

⚛ A pure JavaScript, performant, typed shimmer component for Android, iOS and Web
TypeScript
41
star
10

react-native-applifecycle

⚛ Enhances the reliability of managing app lifecycles across iOS and Android platforms, ensuring consistent behavior regarding foreground and background states.
TypeScript
39
star
11

electron-webpack-react-boilerplate

Sample project containing Electron Forge + webpack + React + React Router + Ant Design + Recharts + Sass and Less.
JavaScript
26
star
12

react-native-notifree

*DEPRECATED* Free React Native library to display local notifications.
JavaScript
22
star
13

react-native-easybluetooth-le

A Library for easy implementation of Serial Bluetooth Low Energy on React Native. ⚛
Java
18
star
14

react-recaptcha-that-works

⚛ A reCAPTCHA bridge for React that works.
TypeScript
16
star
15

DouglasJuniorTCC

Software para mineração e medição de dados do GitHub.
Java
10
star
16

LaTeX-PPGI-UTFPR

Template LaTeX para criação do PDM/Dissertação de acordo com as normas da UTFPR
TeX
10
star
17

Facebug

Rede social em desenvolvimento pelos alunos de Programação Web 2015/1 do curso de ADS da Faculdade Integrado
Java
9
star
18

Bootcamp-DB1-2024

JavaScript
8
star
19

learning-react

JavaScript
7
star
20

WebDevAlfa-2018-React

Desenvolvimento Web com React JS
JavaScript
7
star
21

WebDevAlfa-2017-2-PrimeiroProjeto

Projeto "Hello World" utilizado como introdução ao framework React Native na Pós-graduação WebDev Alfa.
JavaScript
6
star
22

Treinamento-JavaScript-UTFPR

Conteúdo do treinamento de JavaScript ministrado na UTFPR-CM.
JavaScript
6
star
23

RhinoAndroidTest

JavaScript interpretation with Rhino
Java
5
star
24

simple-csv-editor

Simples editor de CSV para auxiliar no setup de máquinas pick and place.
Java
4
star
25

react-native-inputAccessoryView

Project to simulate the inputAccessoryView problem
Objective-C
4
star
26

programacao-web-2018-2

Repositório para os arquivos das aulas de Programação Web.
Java
4
star
27

conccepar-caprover-workshop

Minicurso: Como instalar e configurar um PaaS em minutos!
4
star
28

ignore-dependency-scripts

Script to prevent dependencies to execute post/pre install scripts when installed directly from git.
JavaScript
4
star
29

WebDevAlfa-2017-2-Avaliacao

Avaliação da disciplina de Desenvolvimento de Aplicações Híbridas.
Objective-C
4
star
30

WebDevAlfa-2019-Node

Desenvolvimento de APIs com Node JS
JavaScript
4
star
31

SampleLibGDX

Sample project for learn libGDX on Android Studio
Java
4
star
32

ohm-to-hass-agent

PowerShell scripts to read sensors from Open Hardware Monitor and return to HASS.Agent.
PowerShell
4
star
33

JavaBlockProgramming

A prototype for control the "execution flow" of the block programming.
Java
3
star
34

java-basic-http_PI4_2016-2

Atividade de implementação de um Servidor HTTP Java para Projeto Integrador IV (2016/2)
Java
3
star
35

meiodia

🕺🍻 Chaaaaaaaama!
JavaScript
3
star
36

TestSwiftRealmAlamofireObjectMapper

Testing Realm Database on iOS Swift project
Swift
3
star
37

nodejs-babel-vscode-debug

Example project to use NodeJS 6 with babel and vscode debug.
JavaScript
3
star
38

WebDevAlfa-2018-Node

Desenvolvimento de APIs com Node JS
JavaScript
3
star
39

CloudTester

Biblioteca de teste e comparação entre APIs de acesso a nuvem.
Java
3
star
40

Treinamento-JavaScript-Mactus

Material do treinamento de JavaScript para a empresa Mactus de Campo Mourão
JavaScript
3
star
41

php-legacy-code-example

CSS
3
star
42

WebDevAlfa-2019-React

Desenvolvimento Web com React JS
JavaScript
3
star
43

MinicursoLibGDX-SNCT2016

Projetos utilizados durante o Minicurso sobre LibGDX do SNCT 2016 em Dois Vizinhos - PR http://semanact.mcti.gov.br/
Java
3
star
44

fabric-icons

This repository is maintained to allow the import of Office Fabric Icons into the react-native-vector-icons
SCSS
3
star
45

SEINFO-2017-JavaScript

Projeto do minicurso de Desenvolvimento Full-stack com JavaScript da SEINFO 2017
JavaScript
3
star
46

Treinamento-JavaScript-SkyPass

Material do treinamento de desenvolvimento Web e Mobile para a empresa SkyPass de Campo Mourão
3
star
47

MinicursoLibGDX-VIICONCCEPAR2016

Projetos utilizados durante o Minicurso sobre LibGDX do VII CONCCEPAR da Faculdade Integrado de Campo Mourão - PR http://conccepar.grupointegrado.br/
Java
3
star
48

react-native-easybluetooth-core

This repository has the CoreModule class used in the libraries react-native-easybluetooth-le and react-native-easybluetooth-classic
Java
3
star
49

GalaxyAsteroidsGameJFX

A simple example of a game developed in JavaFX and Java 8
Java
2
star
50

backend-bootcamp-db1-2024

JavaScript
2
star
51

PrimefacesChartZoomTest

JavaScript
2
star
52

learning-angular2

JavaScript
2
star
53

douglasjunior

2
star
54

SpaceInvaders-LibGDX

Jogo desenvolvido com os alunos de Tópicos Especiais 2015-2 da Faculdade Integrado de Campo Mourão
Java
2
star
55

libgdx-textarea-highlighting

Textarea with code highlighting for LibGDX
Java
2
star
56

backend-bootcamp-db1-2023

JavaScript
2
star
57

CodeProMetrcis2CSV

Simple program for converting CodePro output XML files to CSV
Java
2
star
58

learning-reactnative-redux

Learning Redux with React-Native
JavaScript
2
star
59

MinicursoGit-IXCONCCEPAR

Projetos utilizados durante o Minicurso sobre Git e GitHub do IX CONCCEPAR do Centro Universitário Integrado de Campo Mourão - PR
2
star
60

BichoVsCVSAnalY

Minerador de dados para unir as Issues coletadas pelo Bicho aos Scmlogs coletados pelo CVSAnalY
Java
2
star
61

FlappyBird-LibGDX

Jogo desenvolvido com os alunos de Tópicos Especiais 2015-2 da Faculdade Integrado de Campo Mourão
Java
2
star
62

Treinamento-WebMobile-ExpNordeste

Material do treinamento de desenvolvimento Web e Mobile para a empresa Expresso Nordeste de Campo Mourão
PHP
2
star
63

ProjetoIntegrador2012

Projeto interdisciplinar do 5º período do curso de TSI da UTFPR de Campo Mourão.
PHP
2
star
64

CloudTesterWeb

Implementação da biblioteca CloudTester para comparação entre APIs de acesso a plataformas de nuvem.
Java
2
star
65

SimulandoHerancaMultipla

Exemplo de simulação de herança múltipla de tipos e comportamentos utilizando o modificador "default" do Java 8.
Java
2
star
66

react-native-daylight-saving-date

Sample project to reproduce the issue: Parsing 'daylight saving date' returns wrong date and time on Android.
Objective-C
1
star
67

learning-webpack

JavaScript
1
star
68

MinicursoRest-VICONCCEPAR

Projetos utilizados durante o Minicurso sobre REST do VI CONCCEPAR da Faculdade Integrado de Campo Mourão - PR
Java
1
star
69

frontend-bootcamp-db1-2024

JavaScript
1
star
70

PayaraJCloudsTest

Test project to use JClouds with Payara.
HTML
1
star
71

learning-or-tools

Sample project to learn about Google OR Tools
Python
1
star
72

CadastroPessoaServlet

Disciplina de Programação Web da Faculdade Integrado - Aplicação de cadastro de pessoas utilizando Servlets e cliente Android
Java
1
star
73

apache-jira-miner

Automatically exported from code.google.com/p/apache-jira-miner
Java
1
star
74

react-native-environment-sample

Java
1
star
75

TestingLibrarySample

Java
1
star
76

ExerciciosPOO-PPGI

Java
1
star
77

micro-react-app-example

JavaScript
1
star
78

TestTomEE

Projeto de teste utilizando JSF, EJB, CDI, JPA e JAX-RS com TomEE Plume.
Java
1
star
79

SampleTracker

Android sample tracker
Java
1
star
80

Picaretas

Rede de anúncios em desenvolvimento pelos alunos de Programação Web 2015/2 do curso de ADS da Faculdade Integrado
Java
1
star
81

JavaScriptingTest

Java
1
star
82

node-app-with-docker

JavaScript
1
star
83

react-native-windows-test

C#
1
star
84

topicos-2017-2-frontend

JavaScript
1
star
85

Minicurso-Integrado-2017-JavaScript

Projeto do minicurso de Desenvolvimento Mobile e Backend com JavaScript da Faculdade Integrado.
JavaScript
1
star
86

aula-revisao-de-codigo

Repositório para exemplificar o processo de revisão de código fonte.
1
star
87

Labirinto-LibGDX

Exemplo de criação de labirinto utilizando o conceito de matriz com LibGDX
Java
1
star
88

dispositivos-2018-1-introducao-android

Kotlin
1
star
89

mocha-test

JavaScript
1
star
90

topicos-2017-2-backend

Repositório contendo código Node JS.
JavaScript
1
star
91

dispositivos-2018-01-exemplo-kotlin

Exemplo de projeto Android utilizando Kotlin
Kotlin
1
star
92

repositorio-teste

HTML
1
star
93

db1-code-challange-2019

JavaScript
1
star
94

learning-nextjs

JavaScript
1
star
95

CadastroProdutoServletBD

Disciplina de Programação Web da Faculdade Integrado - Aplicação de cadastro de produtos utilizando Servlets e MySQL
Java
1
star
96

SimuladorJogoDaVida

Atividade para a disciplina de Programação Orientada a Objetos - PPGI - UTFPR-CP
Java
1
star
97

react-native-modules-test

Hello World for native modules in React Native projects.
Objective-C
1
star
98

qualidade-2017-2-bowling-game-kata

Java
1
star
99

MultiOSEngineTest

Project to test the Intel Multi OS Engine
Java
1
star
100

SparkJavaTest

Project to test Spark Java Framework
Java
1
star