I am developing a BLE application on Nexus 4 using Android BLE API. I have a few questions/doubts:
1) Is there a way to set/override the connection or notification i
I met auto disconnection problem same as your second question. Two ways to solve it:
1) Manually pair you Android device with the remote device through Bluetooth setting before running your application.
2) Or you can programmatically pair them in your code. Here's the pairing code I found online, which works for me
private void pairDevice(BluetoothDevice device) {
try {
Log.d("pairDevice()", "Start Pairing...");
Method m = device.getClass()
.getMethod("createBond", (Class[]) null);
m.invoke(device, (Object[]) null);
Log.d("pairDevice()", "Pairing finished.");
} catch (Exception e) {
Log.e("pairDevice()", e.getMessage());
}
}