Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Set;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

public class Main {
    public static boolean checkMusePaired() {
        Set<BluetoothDevice> devices = findPaired();

        if (devices == null || devices.isEmpty()) {
            return false;
        }

        for (BluetoothDevice device : devices) {
            if (device.getName().equalsIgnoreCase("muse")) {
                return true;
            }
        }

        return false;
    }

    public static Set<BluetoothDevice> findPaired() {

        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();

        if (devices == null || devices.isEmpty()) {
            return null;

        } else {
            return devices;
        }

    }
}