好的,我得到了更新,以支持Honeycomb及以上。您需要向界面添加新功能。我这样做了:
interface IBluetoothA2dp {
boolean connectSink(in BluetoothDevice device); // Pre API 11 only
boolean disconnectSink(in BluetoothDevice device); // Pre API 11 only
boolean connect(in BluetoothDevice device); // API 11 and up only
boolean disconnect(in BluetoothDevice device); // API 11 and up only
boolean suspendSink(in BluetoothDevice device); // all
boolean resumeSink(in BluetoothDevice device); // all
BluetoothDevice[] getConnectedSinks(); // change to Set<> once AIDL supports, pre API 11 only
BluetoothDevice[] getNonDisconnectedSinks(); // change to Set<> once AIDL supports,
int getSinkState(in BluetoothDevice device);
boolean setSinkPriority(in BluetoothDevice device, int priority); // Pre API 11 only
boolean setPriority(in BluetoothDevice device, int priority); // API 11 and up only
int getPriority(in BluetoothDevice device); // API 11 and up only
int getSinkPriority(in BluetoothDevice device); // Pre API 11 only
boolean isA2dpPlaying(in BluetoothDevice device); // API 11 and up only}
然后,您需要在调用此接口中的函数之前检查API版本。这是我的例子:
if (android.os.Build.VERSION.SDK_INT < 11) {
IBluetoothA2dp ibta = getIBluetoothA2dp();
try {
Log.d(LOG_TAG, "Here: " + ibta.getSinkPriority(device));
if (ibta != null)
ibta.connectSink(device);
} catch (Exception e) {
Log.e(LOG_TAG, "Error " + e.getMessage());
}
} else {
IBluetoothA2dp ibta = getIBluetoothA2dp();
try {
Log.d(LOG_TAG, "Here: " + ibta.getPriority(device));
if (ibta != null)
ibta.connect(device);
} catch (Exception e) {
Log.e(LOG_TAG, "Error " + e.getMessage());
}
}希望这可以帮助。我能够使用相同的应用程序来使用这两个界面。