Two question on Bluetooth development on Android:
Is there a way to enable Bluetooth to be always on (I might have a long device discovery phase in my applicati
Enabling Bluetooth to be always on, may not be a good decision, if your only concern is long discovery delay ("battery life"-wise).
As for third-party Bluetooth APIs, the only thing that I've heard of is iAnywhere Blue SDK (from Sybase, not free, only evaluation version available), which covers some of the features, that will be supported in the future from the system/bluetooth and bluez packages.
According to the Android's Bluetooth roadmap, most of the long waited things like Java API, Bluetooth 2.1 + EDR will be implemented, at one point in the future.
Good luck with your project.
Bluetooth implementation is now available in the Android 2.0 API. See this and this.
BlueCove is an open-source bluetooth implementation for Java.
It works on a lot of different machines and if correct there is a Android compatible version lurking around somewhere.
private void ensureDiscoverable() {
if(D) Log.d(TAG, "ensure discoverable");
if (mBluetoothAdapter.getScanMode() !=
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
}
http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#ACTION_REQUEST_DISCOVERABLE
On 2.3.6 I can keep the device always visible by putting the delay 0:
Intent di = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
di.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
The Bluez stack on Linux is an open source implementation. It's also available on Windows but the API is much more complete on Linux.
When you say, 'enable Bluetooth to always be on' do you mean, always trying to discover other devices?
Most bluetooth chips have a deep sleep mode, where the chip is mostly down and just comes up a to check for activity on any established links. It will only wake up to full power when you want it to do something (discovery, make a connection) or there is activity on an existing link.
Yeah, it uses more battery power than if the Bluetooth were totally off but it's not a total vampire.