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

How to capture key events from bluetooth headset with android

Add a broadcast listener to MEDIA_BUTTON: <intent-filter android:priority=”<some number>”> <action android:name=”android.intent.action.MEDIA_BUTTON” /> </intent-filter> You should register your broadcast receiver inside your application (not in manifest file). Otherwise Google Music player will catch your broadcast and aboard it. Your IntentFilter priority should be higher that other media players priorities in your phone) Add android.permission.BLUETOOTH permission in … Read more

Communicating between iOS and Android with Bluetooth LE

I’ve already gone through this for at least one week having this same issue. I’ve already asked a question here and I’ve already answered on my own. The main problem is an Android BUG issue. It’s sending a non permitted command on a fixed L2CAP channnel. But when Android is communicating with normal peripheral BLE … Read more

Android 12 New Bluetooth Permissions

100% working solution : no need any 3rd party plugin manifest code: <!–BLUETOOTH PERMISSION–> <!– Request legacy Bluetooth permissions on older devices. –> <uses-permission android:name=”android.permission.BLUETOOTH” /> <uses-permission android:name=”android.permission.BLUETOOTH_ADMIN” /> <!– Needed only if your app looks for Bluetooth devices. If your app doesn’t use Bluetooth scan results to derive physical location information, you can strongly … Read more

Find all Bluetooth devices (headsets, phones etc) nearby, without forcing the devices in discoverable mode

So, here’s all I found after reading blogs, threads, documentations, SO answers etc. regarding Android’s bluetooth discovery. Thought this might be useful to post my findings here. So before someone starts reading, I want to clarify that, I could not find any way to detect a bluetooth device nearby which is turned on but not … Read more

Android Broadcast Receiver bluetooth events catching

In order to catch Bluetooth state changes (STATE_OFF, STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF), do this: First, add Bluetooth permission to your AndroidManifest file: <uses-permission android:name=”android.permission.BLUETOOTH” /> Create a BroadcastReceiver in your Activity or Service: private final BroadcastReceiver mBroadcastReceiver1 = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) … Read more

Android 4.3 Bluetooth Low Energy unstable

Important implementation hints (Perhaps some of those hints aren’t necessary anymore due to Android OS updates.) Some devices like Nexus 4 with Android 4.3 take 45+ seconds to connect using an existing gatt instance. Work around: Always close gatt instances on disconnect and create a fresh instance of gatt on each connect. Don’t forget to … Read more