All Questions
Tagged with android-bluetooth sockets
36
questions
0
votes
0
answers
33
views
Android bluetooth read/write crashes when job cancelled
I am writing an Android App that connects to an OBD2 bluetooth device and reads ECU data from a vehicle. I create a bluetooth socket and open an input and output stream on the socket. I call a ...
0
votes
2
answers
355
views
How to handle writing to an OutputStream of BluetoothSocket in Android?
The Android developer docs say that the read(byte[]) and write(byte[]) functions both are blocking calls so they should not be called directly from the main thread.
I understand that read() only ...
1
vote
1
answer
1k
views
how to solve bluetooth connect() fails socket might be close
I'm trying to make an app that communicates with nearby devices.
My app is composed of the main activity that asks to enable bluetooth and sets the discoverable mode, so it waits for a connection to ...
0
votes
1
answer
2k
views
BluetoothDevice.createrfcommsockettoservicerecord is Null
I have successfully recognised the bluetooth device (HC-05), I got its name, MAC address, and bond state, but when I'm trying to create a client socket in order to initiate a bluetooth connection with ...
0
votes
0
answers
364
views
What's a good way to keep a bluetooth connection alive and available?
What I've tried so far is to close the socket and open a new one every 15 seconds. Is that reliable?
Trying to keep a connection with a bluetooth printer
0
votes
1
answer
2k
views
Android bluetooth printer - detect disconnection/write failure event?
I'm writing an application that connects to a bluetooth printer and send it messages.
However, I didn't find the right way to detect if there was an error during writing to the printer (such as ...
0
votes
0
answers
1k
views
How to create a Bluetooth Server Socket Connection inside a bluetooth BroadcastReceiver in Android?
The context is the following, I have an Android App that launch an activity when a specific device connects to it, and send a code message. The device is not another android app, in such case the ...
1
vote
1
answer
78
views
Differentiate between "out of range" or "in range, but no listening server socket"? (Bluetooth)
Problem
How can I differentiate between being unable to establish a Bluetooth connection with a remote Android device because:
scenario 1: the remote device is out of range, or its Bluetooth is ...
1
vote
1
answer
2k
views
InputStream not receiving data via Bluetooth
EDIT 1: MCVE-
I let my entire code be in the main question, but since I was asked for an MCVE-
The device is not receiving the data sent to it by the other connected Android device. Code is not ...
0
votes
0
answers
77
views
Bluetooth java.io.IOException: read failed, socket might closed or timeout, read ret: -1 [duplicate]
I tried to connect a barcode scanner with my app via bluetooth. However, bluetoothSocket.connect() returns this error -
java.io.IOException: read failed, socket might closed or timeout, read ret: -1.
...
1
vote
0
answers
780
views
Get the Bluetooth headphone MAC address as it is connected in A2DP
Goal: open a bluetooth socket to a currently connected A2DP device, when I know it is connected.
In order to connect the socket, I need the MAC address of this device.
As i currently understand, ...
3
votes
0
answers
246
views
TLS implementation for Bluetooth [closed]
How to implement TLS for Bluetooth application? I have to send and receive data over Bluetooth between android app and desktop application (python).
Please guide if someone had done this before.
0
votes
1
answer
120
views
In documentation, why is BluetoothServerSocket.accept() called in a while loop if it blocks the thread anyway?
In the android documentation, the following code occurs in the run() segment of a thread:
BluetoothSocket socket = null;
// Keep listening until exception occurs or a socket is returned
...
9
votes
4
answers
991
views
How can I close BluetoothSocket's on screen rotation in Android?
I am making an application which uses bluetooth connection. I am calling bluetooth connection in onCreate() and closing it in onDestroy() of MainActivity:
// Bluetooth
private Bluetooth bt;
private ...
0
votes
1
answer
306
views
Android Bluetooth Connection between two devices programmatically Fails
I am trying to connect to devices via bluetooth. When I hit the search button everything is good. Also when I click the device from the Detected Devices list also they get paired correctly. But when I ...