Code example for BluetoothAdapter

Methods: getScanMode, isEnabled

0
        @Override 
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction(); 
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { 
                Log.d(TAG, "BT Action State Changed!"); 
                if (mBluetoothAdapter.isEnabled()) { 
                    Log.d(TAG, "BT Enabled"); 
                    Log.d(TAG, "Checking BT Discoverable"); 
                    if (mBluetoothAdapter.getScanMode() == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { 
                        Log.d(TAG, "BT Discoverable"); 
                    } 
                    else { 
                        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); 
                        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 120); 
                        context.startActivity(discoverableIntent); 
                        Log.d(TAG, "BT is NOT Discoverable yet"); 
                    } 
                } 
            } 
        } 
    };