Java Code Examples for android.bluetooth.BluetoothDevice#ACTION_BOND_STATE_CHANGED
The following examples show how to use
android.bluetooth.BluetoothDevice#ACTION_BOND_STATE_CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: G5CollectionService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { initScanCallback(); } advertiseTimeMS.add((long)0); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(true); // TODO check this //bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected // handler = new Handler(getApplicationContext().getMainLooper()); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED);//KS turn on bondintent.addAction(BluetoothDevice.ACTION_FOUND);//KS add registerReceiver(mPairReceiver, bondintent);//KS turn on final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST); pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); registerReceiver(mPairingRequestRecevier, pairingRequestFilter); }
Example 2
Source File: SerialSocket.java From SimpleBluetoothLeTerminal with MIT License | 6 votes |
private void onPairingBroadcastReceive(Context context, Intent intent) { // for ARM Mbed, Microbit, ... use pairing from Android bluetooth settings // for HM10-clone, ... pairing is initiated here BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if(device==null || !device.equals(this.device)) return; switch (intent.getAction()) { case BluetoothDevice.ACTION_PAIRING_REQUEST: final int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, -1); Log.d(TAG, "pairing request " + pairingVariant); onSerialConnectError(new IOException(context.getString(R.string.pairing_request))); // pairing dialog brings app to background (onPause), but it is still partly visible (no onStop), so there is no automatic disconnect() break; case BluetoothDevice.ACTION_BOND_STATE_CHANGED: final int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1); final int previousBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1); Log.d(TAG, "bond state " + previousBondState + "->" + bondState); break; default: Log.d(TAG, "unknown broadcast " + intent.getAction()); break; } }
Example 3
Source File: DfuBaseService.java From microbit with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); initialize(); final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); final IntentFilter actionFilter = makeDfuActionIntentFilter(); manager.registerReceiver(mDfuActionReceiver, actionFilter); registerReceiver(mDfuActionReceiver, actionFilter); // Additionally we must register this receiver as a non-local to get broadcasts from the notification actions final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED); registerReceiver(mConnectionStateBroadcastReceiver, filter); final IntentFilter bondFilter = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mBondStateBroadcastReceiver, bondFilter); }
Example 4
Source File: G5CollectionService.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { initScanCallback(); } advertiseTimeMS.add((long)0); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(true); // TODO check this //bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected // handler = new Handler(getApplicationContext().getMainLooper()); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED);//KS turn on bondintent.addAction(BluetoothDevice.ACTION_FOUND);//KS add registerReceiver(mPairReceiver, bondintent);//KS turn on final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST); pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); registerReceiver(mPairingRequestRecevier, pairingRequestFilter); }
Example 5
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); readData = new ReadDataShare(this); service = this; foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected instance = JoH.ts(); }
Example 6
Source File: DexShareCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); readData = new ReadDataShare(this); service = this; foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected instance = JoH.ts(); }
Example 7
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); readData = new ReadDataShare(this); service = this; foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); }
Example 8
Source File: DexShareCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate: ENTER"); readData = new ReadDataShare(this); service = this; //KS foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); //KS foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //KS bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected instance = JoH.ts(); }
Example 9
Source File: ShareTest.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share_test); button = (Button) findViewById(R.id.connect); closeButton = (Button) findViewById(R.id.closeConnect); bondButton = (Button) findViewById(R.id.bond); readButton = (Button) findViewById(R.id.read); details = (TextView) findViewById(R.id.connection_details); addListenerOnButton(); addListenerOnCloseButton(); IntentFilter intent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, intent); }
Example 10
Source File: ShareTest.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share_test); button = (Button) findViewById(R.id.connect); closeButton = (Button) findViewById(R.id.closeConnect); bondButton = (Button) findViewById(R.id.bond); readButton = (Button) findViewById(R.id.read); details = (TextView) findViewById(R.id.connection_details); addListenerOnButton(); addListenerOnCloseButton(); IntentFilter intent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, intent); }
Example 11
Source File: ShareTest.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share_test); button = (Button) findViewById(R.id.connect); closeButton = (Button) findViewById(R.id.closeConnect); bondButton = (Button) findViewById(R.id.bond); readButton = (Button) findViewById(R.id.read); details = (TextView) findViewById(R.id.connection_details); addListenerOnButton(); addListenerOnCloseButton(); IntentFilter intent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, intent); }
Example 12
Source File: DexShareCollectionService.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); readData = new ReadDataShare(this); service = this; foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected }
Example 13
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate: ENTER"); readData = new ReadDataShare(this); service = this; //KS foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), service); //KS foregroundServiceStarter.start(); final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //KS bgToSpeech = BgToSpeech.setupTTS(getApplicationContext()); //keep reference to not being garbage collected instance = JoH.ts(); }
Example 14
Source File: BroadcastReceiverDelegator.java From blue-pair with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.d(TAG, "Incoming intent : " + action); switch (action) { case BluetoothDevice.ACTION_FOUND : // Discovery has found a device. Get the BluetoothDevice // object and its info from the Intent. BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Log.d(TAG, "Device discovered! " + BluetoothController.deviceToString(device)); listener.onDeviceDiscovered(device); break; case BluetoothAdapter.ACTION_DISCOVERY_FINISHED : // Discovery has ended. Log.d(TAG, "Discovery ended."); listener.onDeviceDiscoveryEnd(); break; case BluetoothAdapter.ACTION_STATE_CHANGED : // Discovery state changed. Log.d(TAG, "Bluetooth state changed."); listener.onBluetoothStatusChanged(); break; case BluetoothDevice.ACTION_BOND_STATE_CHANGED : // Pairing state has changed. Log.d(TAG, "Bluetooth bonding state changed."); listener.onDevicePairingEnded(); break; default : // Does nothing. break; } }
Example 15
Source File: ShareTest.java From xDrip with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_share_test); button = (Button) findViewById(R.id.connect); closeButton = (Button) findViewById(R.id.closeConnect); bondButton = (Button) findViewById(R.id.bond); readButton = (Button) findViewById(R.id.read); details = (TextView) findViewById(R.id.connection_details); addListenerOnButton(); addListenerOnCloseButton(); IntentFilter intent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, intent); }
Example 16
Source File: AvailableDevicesFragment.java From wearmouse with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (getContext() == null) { Log.w(TAG, "BluetoothScanReceiver context disappeared"); return; } final String action = intent.getAction(); final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); switch (action == null ? "" : action) { case BluetoothDevice.ACTION_FOUND: if (hidDeviceProfile.isProfileSupported(device)) { addAvailableDevice(device); } break; case BluetoothAdapter.ACTION_DISCOVERY_STARTED: initiateScanDevices.setEnabled(false); initiateScanDevices.setTitle(R.string.pref_bluetoothScan_scanning); break; case BluetoothAdapter.ACTION_DISCOVERY_FINISHED: initiateScanDevices.setEnabled(true); initiateScanDevices.setTitle(R.string.pref_bluetoothScan); break; case BluetoothDevice.ACTION_BOND_STATE_CHANGED: updateAvailableDevice(device); break; case BluetoothDevice.ACTION_NAME_CHANGED: BluetoothDevicePreference pref = findDevicePreference(device); if (pref != null) { pref.updateName(); } break; default: // fall out } }
Example 17
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void bondDevice() { final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); if(!share2){ device.setPin("000000".getBytes()); } device.createBond(); }
Example 18
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void bondDevice() { final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); if(!share2){ device.setPin("000000".getBytes()); } device.createBond(); }
Example 19
Source File: DexShareCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void bondDevice() { final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); if(!share2){ device.setPin("000000".getBytes()); } device.createBond(); }
Example 20
Source File: DexShareCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void bondDevice() { final IntentFilter bondintent = new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mPairReceiver, bondintent); if(!share2){ device.setPin("000000".getBytes()); } device.createBond(); }