Example usage for android.content Context BLUETOOTH_SERVICE

List of usage examples for android.content Context BLUETOOTH_SERVICE

Introduction

In this page you can find the example usage for android.content Context BLUETOOTH_SERVICE.

Prototype

String BLUETOOTH_SERVICE

To view the source code for android.content Context BLUETOOTH_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.bluetooth.BluetoothManager for using Bluetooth.

Usage

From source file:Main.java

/** get BluetoothManager */
public static BluetoothManager getManager(Context context) {
    return (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
}

From source file:Main.java

public static boolean isEnabled(Context context) {
    return ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter().isEnabled();
}

From source file:Main.java

/** get BluetoothManager */
@SuppressLint("ServiceCast")
public static BluetoothManager getManager(Context context) {
    return (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
}

From source file:Main.java

public static BluetoothAdapter getBluetoothAdapter(Context context) {
    if (context == null) {
        return null;
    }/*from ww w .ja va 2s  .  c o  m*/
    return ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
}

From source file:Main.java

public static BluetoothManager getBluetoothManager(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return (BluetoothManager) (context.getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE));
    }/*from w  ww.  j  a v  a2s  . c  om*/
    return null;
}

From source file:Main.java

public static BluetoothAdapter getBluetoothAdapter(Context ctx) {
    final BluetoothManager bluetoothManager = (BluetoothManager) ctx
            .getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = bluetoothManager.getAdapter();
    return mBluetoothAdapter;
}

From source file:Main.java

public static BluetoothAdapter getAdapter(Context context) {
    // Initializes Bluetooth adapter.
    final BluetoothManager bluetoothManager = (BluetoothManager) context
            .getSystemService(Context.BLUETOOTH_SERVICE);
    return bluetoothManager.getAdapter();
}

From source file:Main.java

private static void prepareBTAdapter(final Activity activity) {
    // Initializes Bluetooth adapter.
    BluetoothManager bluetoothManager = (BluetoothManager) activity.getSystemService(Context.BLUETOOTH_SERVICE);

    bluetoothAdapter = bluetoothManager.getAdapter();
}

From source file:Main.java

public static BluetoothAdapter getBluetoothAdapter(Context context) {
    // Initializes a Bluetooth adapter.  For API level 18 and above, get a reference to
    // BluetoothAdapter through BluetoothManager.
    final BluetoothManager bluetoothManager = (BluetoothManager) context
            .getSystemService(Context.BLUETOOTH_SERVICE);
    if (bluetoothManager == null) {
        return null;
    }// w w  w  . j  a v  a2s .c  o m
    return bluetoothManager.getAdapter();
}

From source file:Main.java

/**
 * Gets instance of BluetoothManager./*  www .  j ava 2s. co m*/
 * @param context context of application
 * @return Instance of BluetoothManager or null if the BluetoothManager does not exist.
 */
public static BluetoothManager getManager(final Context context) {
    return (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
}