Example usage for android.bluetooth BluetoothAdapter SCAN_MODE_CONNECTABLE_DISCOVERABLE

List of usage examples for android.bluetooth BluetoothAdapter SCAN_MODE_CONNECTABLE_DISCOVERABLE

Introduction

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

Prototype

int SCAN_MODE_CONNECTABLE_DISCOVERABLE

To view the source code for android.bluetooth BluetoothAdapter SCAN_MODE_CONNECTABLE_DISCOVERABLE.

Click Source Link

Document

Indicates that both inquiry scan and page scan are enabled on the local Bluetooth adapter.

Usage

From source file:Main.java

public static boolean isDiscoverable() {
    BluetoothAdapter bluetoothDefaultAdapter = BluetoothAdapter.getDefaultAdapter();
    if ((bluetoothDefaultAdapter != null) && (bluetoothDefaultAdapter.isEnabled())) {
        if (bluetoothDefaultAdapter.getScanMode() == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
            return true;
    }/*  w  w  w. j ava  2s. c o m*/
    return false;
}

From source file:Main.java

static public String scanMode2String(int scanMode) {
    final String NONE = "SCAN_MODE_NONE";
    final String CONNECTABLE = "SCAN_MODE_CONNECTABLE";
    final String CONNECTABLE_DISCOVERABLE = "SCAN_MODE_CONNECTABLE_DISCOVERABLE";

    switch (scanMode) {
    case BluetoothAdapter.SCAN_MODE_NONE:
        return NONE;
    case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
        return CONNECTABLE;
    case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
        return CONNECTABLE_DISCOVERABLE;
    default://w  w w .  j  av a 2s .c om
        return UNKNOWN;
    }
}

From source file:scmu.nutweet.bluetooth.BluetoothChat.java

private void ensureDiscoverable() {
    if (D)/*from w  w w  . j  ava2  s  .c  o  m*/
        Log.d(TAG, "ensure discoverable");
    if (Const.mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
}

From source file:org.thaliproject.p2p.btpollingsynclib.BtPollingSyncService.java

@Override
public void BluetoothStateChanged(int state) {
    if (state == BluetoothAdapter.SCAN_MODE_NONE) {
        print_line("BT", "Bluetooth DISABLED, stopping");
        stopAll();/* ww w.jav a  2s  . c  o  m*/
    } else if (state == BluetoothAdapter.SCAN_MODE_CONNECTABLE
            || state == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        print_line("BT", "Bluetooth enabled, re-starting");
        startAll();
    }
}

From source file:app.park.com.bluetooth.BluetoothFragment.java

/**
 * Makes this device discoverable.//from  ww w  .  j a va 2 s .com
 */
public void ensureDiscoverable() {
    if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Toast.makeText(getActivity(), "Role : BT Controller ", Toast.LENGTH_SHORT).show();
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
}

From source file:com.example.android.bluetoothchat.LobbyActivity.java

private void ensureDiscoverable() {
    if (mBtAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
        startActivity(discoverableIntent);
    }/*from   w ww  . java 2s.c o  m*/
}

From source file:net.cherryzhang.sekuhara.BluetoothButtonAndChat.BluetoothChat.BluetoothChat.java

public void ensureDiscoverable() {
    if (D)//  w  w  w  . j a v a  2 s.  c  o  m
        Log.d(TAG, "ensure discoverable");
    if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
}

From source file:com.bluetooth.comp529.bluetoothchatproj.chat.BluetoothChatFragment.java

/**
 * Makes this device discoverable./*from   www .ja v  a 2 s. c  o  m*/
 */
private void ensureDiscoverable() {
    // check scan mode so that way we do not have to ask again once discoverable.
    if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
        startActivity(discoverableIntent);
    }
}

From source file:com.authorwjf.bounce.BluetoothChat.java

private void ensureDiscoverable() {
    if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }//from  ww w.j  a  v a 2 s.  c o  m
}

From source file:johmphot.card.bluetooth.MultiplayerGameActivity.java

/**
 * Makes this device discoverable.//from   w  ww. ja v  a2 s.co  m
 */
private void ensureDiscoverable() {
    if (btAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
}