Sunday, April 21, 2013
Thursday, April 11, 2013
Finally making progress on Jelly Bean 4.2 Bluetooth interfaces
I finally purchased a Droid Bionic on eBay to use as my primary phone so I could put CM10.1 (Android 4.2.2) on the old Droid 3. Last night I finally got the IBluetoothA2dp interface working with CM10.1, sort of. I implemented what I have so far in A2DP Connect 1.0.14 (now available for download). It does not work on the first try since the binder to the interface finishes after the call to use it. I need to redo a bunch of things to fix that but at least I know how to use the interface now which is a huge step.
It starts with this
Intent i = new Intent(IBluetoothA2dp.class.getName());
if (context.bindService(i, mConnection, Context.BIND_AUTO_CREATE)) {
return ibta2;
This calls mConnection:
public static ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
ibta2 = IBluetoothA2dp.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
}
};
mConnection gets called when the service is connected or disconnected calling the functions within it. The problem is that these calls happen after the ibta2 is needed. So, the function I have in the code to get the ibta2 tries to use it before it is returned. This stays bound though so the 2nd attempt worked because the prior attempt actually bound the service and kept it.
More work to do be done but significant progress. It REALLY helps having a 4.2 device to test with. Before that I was just guessing and hoping someone else would test. I also did not have logcat to see what was going on.
It starts with this
Intent i = new Intent(IBluetoothA2dp.class.getName());
if (context.bindService(i, mConnection, Context.BIND_AUTO_CREATE)) {
return ibta2;
This calls mConnection:
public static ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
ibta2 = IBluetoothA2dp.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
}
};
mConnection gets called when the service is connected or disconnected calling the functions within it. The problem is that these calls happen after the ibta2 is needed. So, the function I have in the code to get the ibta2 tries to use it before it is returned. This stays bound though so the 2nd attempt worked because the prior attempt actually bound the service and kept it.
More work to do be done but significant progress. It REALLY helps having a 4.2 device to test with. Before that I was just guessing and hoping someone else would test. I also did not have logcat to see what was going on.
Subscribe to:
Posts (Atom)