List of usage examples for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION
String EXTRA_DISCOVERABLE_DURATION
To view the source code for android.bluetooth BluetoothAdapter EXTRA_DISCOVERABLE_DURATION.
Click Source Link
From source file:spring16.cs442.com.obtchat_10.BluetoothChatFragment.java
/** * Makes this device discoverable.//from w ww . ja v a 2 s. com */ 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.molidt.easyandroid.bluetooth.BluetoothFragmentV4.java
public void setDiscoverable(int discoveralbeTime) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, discoveralbeTime); startActivity(discoverableIntent);/*from ww w. jav a 2 s.c o m*/ }
From source file:com.example.bluetooth_faster_connection.MainActivity.java
private void ensureDiscoverable() { if (D)/*from w ww . ja 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, 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()) { }//ww w. ja va 2s. c om 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 a v a2s. co m 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.jtechme.apphub.FDroid.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_update_repo: UpdateService.updateNow(this); return true; case R.id.action_manage_repos: startActivity(new Intent(this, ManageReposActivity.class)); return true; case R.id.action_settings: Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class); startActivityForResult(prefs, REQUEST_PREFS); return true; case R.id.action_swap: startActivity(new Intent(this, SwapWorkflowActivity.class)); return true; case R.id.action_bluetooth_apk: /*/* www . j av a 2s . co m*/ * If Bluetooth has not been enabled/turned on, then enabling * device discoverability will automatically enable Bluetooth */ Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); // if this is successful, the Bluetooth transfer is started return true; case R.id.action_about: View view = LayoutInflater.from(this).inflate(R.layout.about, null); String versionName = Utils.getVersionName(this); if (versionName != null) { ((TextView) view.findViewById(R.id.version)).setText(versionName); } AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create(); alrt.setTitle(R.string.about_title); alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { } }); alrt.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.example.android.naradaonline.DatagramFragment.java
/** * Makes this device discoverable./*from w w w .j av a 2 s. c om*/ */ 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:bluetoothchat.BluetoothChatFragment.java
/** * Makes this device discoverable./*from w w 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 w w w. j a v a 2 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)/*from 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); } }