How to keep Bluetooth connection background?

Yes, I found a working solution for running Bluetooth background in Android. Below is the code I have used in my android app. public class BluetoothServices extends Service { private BluetoothAdapter mBluetoothAdapter; public static final String B_DEVICE = “MY DEVICE”; public static final String B_UUID = “00001101-0000-1000-8000-00805f9b34fb”; // 00000000-0000-1000-8000-00805f9b34fb public static final int STATE_NONE = … Read more

Reading data from bluetooth device in android

I use DataInputStreams instead as you can do a readFully() method which waits to read a certain number of bytes before returning. I setup the BT connection like this: BluetoothDevice btDevice = bta.getRemoteDevice(macAddress); BluetoothSocket btSocket = InsecureBluetooth.createRfcommSocketToServiceRecord( btDevice, UUID.fromString(“00001101-0000-1000-8000-00805F9B34FB”), false); btSocket.connect(); InputStream input = btSocket.getInputStream(); DataInputStream dinput = new DataInputStream(input); then later on when I … Read more

How to unpair or delete paired bluetooth device programmatically on android?

This code works for me. private void pairDevice(BluetoothDevice device) { try { if (D) Log.d(TAG, “Start Pairing…”); waitingForBonding = true; Method m = device.getClass() .getMethod(“createBond”, (Class[]) null); m.invoke(device, (Object[]) null); if (D) Log.d(TAG, “Pairing finished.”); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } private void unpairDevice(BluetoothDevice device) { try { Method m = device.getClass() … Read more

Application using bluetooth SPP profile not working after update from Android 4.2 to Android 4.3

We can confirm the Bluetooth disconnect after 6 seconds when communicating from our Nexus 4 app to an external Bluetooth ECG (medical device) after upgrading from Android 4.2 to 4.3. This happens specifically during an ECG measurement with lots of inbound data (from ECG to the Android app) but no outbound data. “Normal” Bluetooth communication … Read more

how to route iPhone audio to the bluetooth headset

This little test worked for me… it involves setting up the bluetooth headset as the input also (not sure if that’s what you want). Sorry about the crappy formatting on the code… // create and set up the audio session AVAudioSession* audioSession = [AVAudioSession sharedInstance]; [audioSession setDelegate:self]; [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; [audioSession setActive: YES … Read more