Java Code Examples for android.bluetooth.BluetoothDevice#ACTION_NAME_CHANGED
The following examples show how to use
android.bluetooth.BluetoothDevice#ACTION_NAME_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: PairedDevicesFragment.java From wearmouse with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { if (getContext() == null) { Log.w(TAG, "BluetoothScanReceiver got intent with no context"); return; } final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); final String action = intent.getAction(); switch (action == null ? "" : action) { case BluetoothDevice.ACTION_BOND_STATE_CHANGED: updatePreferenceBondState(device); break; case BluetoothDevice.ACTION_NAME_CHANGED: BluetoothDevicePreference pref = findDevicePreference(device); if (pref != null) { pref.updateName(); } break; default: // fall out } }
Example 2
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 3
Source File: BluetoothEventManager.java From talkback with Apache License 2.0 | 5 votes |
/** * Initiates discovery with the associated bluetooth adapter and registers a {@link * BroadcastReceiver} to listen to bluetooth device discovery and pairing events. */ @RequiresPermission(allOf = {permission.BLUETOOTH, permission.BLUETOOTH_ADMIN}) public void initiateDiscovery() { if (!bluetoothAdapter.isDiscovering()) { if (!isDiscoveryAndPairingReceiverRegistered) { IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_NAME_CHANGED); intentFilter.addAction(BluetoothDevice.ACTION_FOUND); intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); context.registerReceiver(discoveryAndPairingReceiver, intentFilter); isDiscoveryAndPairingReceiverRegistered = true; } /* Check for the ACCESS_COARSE_LOCATION permission. If the user denies this permission, no * ACTION_FOUND broadcasts will be received by the discoveryAndPairingReceiver. * ACTION_NAME_CHANGED broadcasts will still be received, though there may be a delay before * users first see discovered devices. * * Applications can handle cases when this permission is denied by overriding {@link * Activity#onActivityResult} and listening for the {@link * BluetoothEventManager#REQUEST_COARSE_LOCATION} request code. */ if (ContextCompat.checkSelfPermission(context, permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( (Activity) context, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_ACCESS_COARSE_LOCATION); } bluetoothAdapter.startDiscovery(); } }