android-bluetooth

Bluetooth not sending file to other device

丶灬走出姿态 提交于 2019-12-04 19:25:19
问题 It is already asked but i didn't find any solution. For bluetooth application i am using the bluetoothShare.class . My source code for sending the file to the target device MainActvity.class: Set<BluetoothDevice> devices = btAdapter .getBondedDevices(); final String btDeviceName = selected_deviceName; BluetoothDevice device = null; for (BluetoothDevice itDevice : devices) { if (btDeviceName.equals(itDevice.getName())) { device = itDevice; } } if (device != null) { ContentValues values = new

Android BLE - Peripheral | onCharacteristicRead return wrong value or part of it (but repeated)

血红的双手。 提交于 2019-12-04 18:49:10
i'm losing my mind with this issue. The fact is, one android device which is advertising a string value: "78d89537-4309-4728-87f6-3ab2bbe231d8" (36 bytes). I'm using a characteristic defined as anonIdCharacteristic = new BluetoothGattCharacteristic(TippeeBluetoothManager.UUID_READ_CHARACTERISTIC, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_BROADCAST, BluetoothGattCharacteristic.PERMISSION_READ ); anonIdCharacteristic.setValue(idToAdvertise); as you can see i'm advertising in "READ" mode, not notify. When another android device connect and try to read the

Pre-pairing bluetooth devices

允我心安 提交于 2019-12-04 17:57:41
问题 I would like to be able to pre-pair bluetooth devices, to save the step of user confusion when using the app. I have discovered that there is a patent for System, method and apparatus for pre-pairing bluetooth enabled devices. I am looking at pairing an array of android devices with an array of embedded devices, so when the android device is set up, I can pre-pair it with the devices it needs to communicate with. I have considered maintaining a list of MAC-addresses that can be downloaded and

How to solve the BluetoothGatt : android.os.DeadObjectException error happened in Android?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 17:01:34
问题 I following the page Bluetooth Low Energy for developing in Android 4.3 for Bluetooth Low Energy . I already can turn on the Bluetooth , scan the device and connect to the BLE device. But it show the BluetoothGatt : android.os.DeadObjectException after I try to connect to device (device.connectGatt) and before discover the Service (mBluetoothGatt.discoverServices) for the BLE device. Before BluetoothGatt : android.os.DeadObjectException it show the log like the following W/bt-smp (10670): io

Bluetooth connect without pairing

久未见 提交于 2019-12-04 13:23:10
问题 The normal way to connect to a bluetooth device is by pairing. We need to connect to a device in an abnormal way: By using the Bluetooth MAC address only. We do not want to be prompted for a PIN. We know the device supports this technique, but we cannot find a way to do it on Android. The abbreviated code looks like this: String mac_address = “00:11:22:33:44:55” BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice bluetoothDevice = mBluetoothAdapter

Android Lollipop BLE scan - getting peripherals without duplications

て烟熏妆下的殇ゞ 提交于 2019-12-04 11:24:51
Android Lollipop introduced a new way to scan for BLE peripherals, via BluetoothLeScanner . From what I read, the new scanning API solved an issue that happened with the old scanning API ( BluetoothAdapter.startLeScan(UUID[],LeScanCallback) ) where on some devices the callback ( onLeScan ) was called only once per peripheral, even if the peripheral keeps advertising. This issue is handled on iOS with the CBCentralManagerScanOptionAllowDuplicatesKey option, that allows you to choose whether you want to detect only new peripherals or keep getting advertisements from previously-found peripherals.

Android Bluetooth background listener

 ̄綄美尐妖づ 提交于 2019-12-04 10:02:50
问题 I am developing an android application with bluetooth chat. I have successfully implemented bluetooth chat with two phones.But my problem is that if I Change to next activity from the chatting activity the connection is lost then I am not able to send messages from second activity. How can I maintain my connection? That is I want to stay connected through out my app. Whenever the user press on exit button then only the connection can disconnect. I want to send message from one activity and

How to check if bluetooth connection to a device is disconnected?

送分小仙女□ 提交于 2019-12-04 08:20:17
I want to know when my bluetooth connection to the device gets disconnected. I found this to check: IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED); IntentFilter filter2 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED); IntentFilter filter3 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED); this.registerReceiver(mReceiver, filter1); this.registerReceiver(mReceiver, filter2); this.registerReceiver(mReceiver, filter3); //The BroadcastReceiver that listens for bluetooth broadcasts mReceiver = new BroadcastReceiver() { @Override public

Getting the renamed name of an Android BluetoothDevice

对着背影说爱祢 提交于 2019-12-04 06:11:28
My android phone allows me rename devices that I have paired with, by going to the [Settings > Wireless & Networkds > Bluetooth] Activity page and clicking the settings button to the right of a paired bluetooth device. However, when I query for a list of Bonded devices with the BluetoothAdapter.getBondedDevices() function, the name that shows up in the results is the default name for the device. How can I access the renamed name for a Bluetooth device? Dmytro Batyuk You should use alias name . For setting rename device: try { Method method = device.getClass().getMethod("setAlias", String.class

How can i use the Bluetooth HID Device profile in Android Pie?

做~自己de王妃 提交于 2019-12-04 05:30:26
I am trying to write an app for Android P using the Bluetooth HID device profile service to be used as a Bluetooth keyboard. According to the documentation I am supposed to use the method BluetoothAdapter.getProfileProxy(Context, BluetoothProfile.ServiceListener, int) to get the BluetoothHidDevice proxy object. During debug on my Android Pie device (Nokia 7 plus) the service listener never get called ( onServiceConnected ), and i get the following error in Logcat: Could not bind to Bluetooth HID Device Service with Intent { act=android.bluetooth.IBluetoothHidDevice } If I change the last param