Open top menu


Example - How to check Bluetooth Off Or On

<uses-permission android:name="android.permission.BLUETOOTH" />

private boolean getBlueToothOn(Context context) {
    BluetoothAdapter btAdapter = ((Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1)
            ? ((BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter()
            : (BluetoothAdapter.getDefaultAdapter()));

    if (btAdapter == null) {
        return false;
    }
    if (btAdapter.getState() == BluetoothAdapter.STATE_ON) {
        return true;
    }
}
Tagged

0 comments