Code example for BluetoothAdapter

Methods: getState

0
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        mIntentFilter = new IntentFilter();
    } 
 
    public boolean isEnabled() { 
        if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON)
            return true; 
        return false; 
    } 
 
    public boolean discoverBTDevices(Context context) {
        if (!isEnabled()) { 
            Log.d(TAG, "BT is disabled!");
            return false; 
        } 
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 120);
        context.startActivity(discoverableIntent);
        return true; 
    } 
Contextual code suggestions in your IDE  Get Codota for Java