Android Open Source - Android-BleEventAdapter Ble Event Adapter

From Project

Back to project page Android-BleEventAdapter.


The source code is released under:

Apache License

If you think the Android project Android-BleEventAdapter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*w  w w .  j  ava 2  s .  c  o  m*/

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;

public class BleEventAdapter {

    private static BleEventAdapter ourInstance = new BleEventAdapter();

    private BluetoothDevice bluetoothDevice;

    public static BleEventAdapter getInstance() {
        return ourInstance;

    public BluetoothDevice getBluetoothDevice() {
        return bluetoothDevice;

    private void setBluetoothDevice(BluetoothDevice bluetoothDevice) {
        this.bluetoothDevice = bluetoothDevice;

    public void connectDevice(Context context, BluetoothDevice device) {
        context.startService(new Intent(context, GattService.class));

    public void closeConnection(Context context) {
        context.stopService(new Intent(context, GattService.class));

    public void startScanning(Context context) {
        context.startService(new Intent(context, DeviceDiscoveryService.class));

    public void stopScanning(Context context) {
        context.stopService(new Intent(context, DeviceDiscoveryService.class));

Java Source Code List