List of usage examples for android.bluetooth BluetoothAdapter SCAN_MODE_CONNECTABLE_DISCOVERABLE
int SCAN_MODE_CONNECTABLE_DISCOVERABLE
To view the source code for android.bluetooth BluetoothAdapter SCAN_MODE_CONNECTABLE_DISCOVERABLE.
Click Source Link
From source file:com.googlecode.android_scripting.facade.BluetoothFacade.java
@Rpc(description = "Requests that the device be discoverable for Bluetooth connections.") public void bluetoothMakeDiscoverable( @RpcParameter(name = "duration", description = "period of time, in seconds, during which the device should be discoverable") @RpcDefault("300") Integer duration) { if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, duration); // Use startActivityForResult to make this a synchronous call. mAndroidFacade.startActivityForResult(discoverableIntent); }/*from w ww. ja v a 2 s.c o m*/ }
From source file:com.duy.pascal.interperter.libraries.android.connection.bluetooth.AndroidBluetoothLib.java
@SuppressWarnings("unused") @PascalMethod(description = "Requests that the device be discoverable for Bluetooth connections.") public void bluetoothMakeDiscoverable( @PascalParameter(name = "duration", description = "period of time, in seconds, during which the device should be discoverable") @RpcDefault("300") Integer duration) { if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, duration); // Use startActivityForResult to make this a synchronous call. mAndroidFacade.startActivityForResult(discoverableIntent); }// w ww.j a v a2 s . c o m }
From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java
private void registerReceivers() { this.broadcastRegistrar = new BroadcastRegistrar(); this.broadcastRegistrar .addLocalAction(ConnectionService.ACTION_HOST_CONNECTED, new IBroadcastActionHandler() { @Override//ww w .j av a2s . c o m public void onReceiveAction(Context context, Intent intent) { joinView.setEnabled(true); joinView.findViewById(R.id.searching).setVisibility(View.INVISIBLE); //switch Transitions.transitionToHome((CoreActivity) getActivity()); ((CoreActivity) getActivity()).enableSlidingMenu(); //add the playbar fragment onto the active content view ((CoreActivity) getActivity()).showPlaybar(); } }).addGlobalAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.SCAN_MODE_NONE); if (joinView != null) { switch (mode) { case BluetoothAdapter.SCAN_MODE_NONE: //fall through to connectable case BluetoothAdapter.SCAN_MODE_CONNECTABLE: isSearching = false; setJoinToDefaultState(); break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: isSearching = true; setJoinToSearchingState(); break; default: Log.wtf(TAG, "Recieved scan mode changed with unknown mode"); break; } } } }).register(this.getActivity()); }
From source file:com.example.hudpassthrough.BluetoothChat.java
private void ensureDiscoverable() { if (D)/*from ww w .j a v a 2s . c om*/ 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:spring16.cs442.com.obtchat_10.BluetoothChatFragment.java
/** * Makes this device discoverable.// w ww . j ava 2s. c o m */ 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, 2000); startActivity(discoverableIntent); } }
From source file:com.example.bluetooth_faster_connection.MainActivity.java
private void ensureDiscoverable() { if (D)/* w w w. ja va 2s . 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, 0); startActivity(discoverableIntent); } }
From source file:org.imdea.panel.MainActivity.java
public void enableBt() { BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mAdapter.isEnabled()) mAdapter.enable(); //Turn On Bluetooth without Permission /*if (!mAdapter.isEnabled()) startActivity(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));*/ while (!mAdapter.isEnabled()) { }// w w w . j a va 2s . c o m String restoredMAC = SP.getString("MAC", null); if (restoredMAC != null) { Global.DEVICE_ADDRESS = restoredMAC; if (restoredMAC.equals("00:00:00:00:00:00")) { Global.DEVICE_ADDRESS = mAdapter.getAddress(); SharedPreferences.Editor editor = SP.edit(); editor.putString("MAC", Global.DEVICE_ADDRESS); editor.apply(); } } else { Global.DEVICE_ADDRESS = mAdapter.getAddress(); SharedPreferences.Editor editor = SP.edit(); editor.putString("MAC", Global.DEVICE_ADDRESS); editor.apply(); } Log.w("MAC", Global.DEVICE_ADDRESS); if (mAdapter.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.example.administrator.myapplication2._3_HB._3_MainActivity.java
/** * Ensure this device is discoverable by others *//*from w w w. j av a 2 s .com*/ private void ensureDiscoverable() { if (mService.getBluetoothScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(intent); } }
From source file:com.googlecode.android_scripting.facade.BluetoothFacade.java
@Rpc(description = "Gets the scan mode for the local dongle.\r\n" + "Return values:\r\n" + "\t-1 when Bluetooth is disabled.\r\n" + "\t0 if non discoverable and non connectable.\r\n" + "\r1 connectable non discoverable." + "\r3 connectable and discoverable.") public int bluetoothGetScanMode() { if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF || mBluetoothAdapter.getState() == BluetoothAdapter.STATE_TURNING_OFF) { return -1; }//from ww w. j ava2 s .c om switch (mBluetoothAdapter.getScanMode()) { case BluetoothAdapter.SCAN_MODE_NONE: return 0; case BluetoothAdapter.SCAN_MODE_CONNECTABLE: return 1; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: return 3; default: return mBluetoothAdapter.getScanMode() - 20; } }
From source file:com.duy.pascal.interperter.libraries.android.connection.bluetooth.AndroidBluetoothLib.java
@SuppressWarnings("unused") @PascalMethod(description = "Gets the scan mode for the local dongle.\r\n" + "Return values:\r\n" + "\t-1 when Bluetooth is disabled.\r\n" + "\t0 if non discoverable and non connectable.\r\n" + "\r1 connectable non discoverable." + "\r3 connectable and discoverable.") public int bluetoothGetScanMode() { if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF || mBluetoothAdapter.getState() == BluetoothAdapter.STATE_TURNING_OFF) { return -1; }/*w w w . j a v a2s. c om*/ switch (mBluetoothAdapter.getScanMode()) { case BluetoothAdapter.SCAN_MODE_NONE: return 0; case BluetoothAdapter.SCAN_MODE_CONNECTABLE: return 1; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: return 3; default: return mBluetoothAdapter.getScanMode() - 20; } }