Example usage for android.bluetooth BluetoothAdapter getDefaultAdapter

List of usage examples for android.bluetooth BluetoothAdapter getDefaultAdapter

Introduction

In this page you can find the example usage for android.bluetooth BluetoothAdapter getDefaultAdapter.

Prototype

public static synchronized BluetoothAdapter getDefaultAdapter() 

Source Link

Document

Get a handle to the default local Bluetooth adapter.

Usage

From source file:Main.java

public static boolean isBluetoothSupported() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter == null) {
        // Device does not support Bluetooth
        return false;
    } else {//from w w w .  j a v  a 2  s.  c  o m
        return true;
    }
}

From source file:Main.java

public static boolean isBluetoothSupported() {
    return BluetoothAdapter.getDefaultAdapter() != null;
}

From source file:Main.java

public static boolean enableBluetooth(boolean bEnable) {
    BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
    if (btAdapter == null) {
        // Bluetooth not supported
        return false;
    }//from w w  w. jav a  2s. co  m

    return bEnable ? btAdapter.enable() : btAdapter.disable();
}

From source file:Main.java

public static BluetoothAdapter getBTAdapter() {
    return BluetoothAdapter.getDefaultAdapter();
}

From source file:Main.java

public static void onBluetooth() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (!bluetoothAdapter.isEnabled()) {
        bluetoothAdapter.enable();//from   w  w w  .  jav  a2 s .c  o m
        Log.i("Log", "Bluetooth is Enabled");
    }
}

From source file:Main.java

static public boolean checkBluetoothAvaliability() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter == null) {
        return false;
    } else {//w w w.  j a  v  a2 s  .  c om
        if (mBluetoothAdapter.isEnabled()) {
            return true;
        } else {
            return false;
        }
    }
}

From source file:Main.java

public static void openBt() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    mBluetoothAdapter.enable();
}

From source file:Main.java

public static void closeBt() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    mBluetoothAdapter.disable();
}

From source file:Main.java

public static boolean isOpenBt() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    return mBluetoothAdapter.isEnabled();
}

From source file:Main.java

public static void stopBtSearch() {
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    mBluetoothAdapter.cancelDiscovery();
}