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.thelastcrusade.soundstream.components.NetworkFragment.java
private void registerReceivers() { this.broadcastRegistrar = new BroadcastRegistrar(); this.broadcastRegistrar .addLocalAction(ConnectionService.ACTION_FIND_FINISHED, new IBroadcastActionHandler() { @Override/* w w w.j ava2s. co m*/ public void onReceiveAction(Context context, Intent intent) { onFindFinished(intent); } }).addLocalAction(UserList.ACTION_USER_LIST_UPDATE, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { updateUserView(); } }).addLocalAction(ConnectionService.ACTION_GUEST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }).addLocalAction(ConnectionService.ACTION_HOST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }).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 (joinDifferentNetworkButton != null) { switch (mode) { case BluetoothAdapter.SCAN_MODE_NONE: case BluetoothAdapter.SCAN_MODE_CONNECTABLE: setButtonToDefaultState(joinDifferentNetworkButton); isSearchingJoinDifferent = false; break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: setButtonToSearchingState(joinDifferentNetworkButton); isSearchingJoinDifferent = true; break; default: Log.wtf(TAG, "Recieved scan mode changed with unknown mode"); break; } } } }).register(this.getActivity()); }
From source file:com.example.android.naradaonline.DatagramFragment.java
/** * Makes this device discoverable./* www . j ava 2 s . 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, 300); startActivity(discoverableIntent); } }
From source file:au.gov.ga.worldwind.androidremote.client.Remote.java
protected void ensureDiscoverable() { if (bluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); startActivity(discoverableIntent); }/*w ww . jav a 2s . c o m*/ }
From source file:bluetoothchat.BluetoothChatFragment.java
/** * Makes this device discoverable./* ww w .j ava 2s . c o m*/ */ public 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 source file:flex.android.magiccube.activity.ActivityBattleMode.java
private void ensureDiscoverable() { if (mBluetoothAdapter == null) { return;/*from ww w . j a va2 s . c o m*/ } if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivityForResult(discoverableIntent, REQUEST_DISCOVERABLE); } }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@SuppressLint("NewApi") private void ensureDiscoverable() { if (D)/* ww w .ja va 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:flex.android.magiccube.activity.ActivityBattleMode.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CONNECT_DEVICE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { // Get the device MAC address String address = data.getExtras().getString(ActivityClient.EXTRA_DEVICE_ADDRESS); // Get the BLuetoothDevice object BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); // Attempt to connect to the device mChatService.connect(device); }//from w w w . j a va2 s . c o m break; case REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { // Bluetooth is now enabled, so set up a chat session setupChat(); Intent intent = new Intent(this, ActivityTab.class); startActivityForResult(intent, REQUEST_SETTING); } else { // User did not enable Bluetooth or an error occured Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show(); finish(); } break; case REQUEST_SETTING: if (resultCode == Activity.RESULT_OK) { // Log.e("ok","ok"); if (MagiccubePreference.GetPreference(MagiccubePreference.ServerOrClient, this) == 1) { /* * if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent * = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); * startActivityForResult(enableIntent, REQUEST_ENABLE_BT); * // Otherwise, setup the chat session } else { if * (mChatService == null) setupChat(); } */ if (mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) { ensureDiscoverable(); } else { this.showWait("..."); } } else if (MagiccubePreference.GetPreference(MagiccubePreference.ServerOrClient, this) == 0) { String address = this .getSharedPreferences(MagiccubePreference.SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE) .getString(MagiccubePreference.ServerAddress, ""); // Get the BLuetoothDevice object BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); // Attempt to connect to the device mChatService.connect(device); } else { finish(); } } break; case REQUEST_DISCOVERABLE: // Log.e("resultCode", resultCode+""); if (resultCode > 0) { this.showWait("..."); } else { mHandler.sendEmptyMessage(NOT_ENABLE_DISCOVERY); } break; } }