怎么没有人回复呢,自己顶一下,
是不是还需要添加这个代码:
if (mService.getSinkPriority(device) > BluetoothA2dp.PRIORITY_ON) {
mService.setSinkPriority(audioDevice,
BluetoothA2dp.PRIORITY_ON);
if (D)
Log.d(TAG, "isPreferred PRIORITY_ON== true");
}
在Settings源码中有看到,但是这个需要系统权限,我没法尝试,
是不是还需要添加这个代码:
if (mService.getSinkPriority(device) > BluetoothA2dp.PRIORITY_ON) {
mService.setSinkPriority(audioDevice,
BluetoothA2dp.PRIORITY_ON);
if (D)
Log.d(TAG, "isPreferred PRIORITY_ON== true");
}
在Settings源码中有看到,但是这个需要系统权限,我没法尝试,
那有没有知道怎样反射到BluetoothHeadset类啊???
Class<?> c2;
c2 = Class.forName("android.os.ServiceManager");
Method m2 = c2.getDeclaredMethod("getService", String.class);
IBinder b = (IBinder) m2.invoke(null, "bluetooth_a2dp");
Class<?> c3 = Class.forName("android.bluetooth.IBluetoothA2dp");
Class[] s2 = c3.getDeclaredClasses();
Class<?> c = s2[0];
// printMethods(c);
Method m = c.getDeclaredMethod("asInterface", IBinder.class);
m.setAccessible(true);
ibta = (IBluetoothA2dp) m.invoke(null, b);
ibta.connect(Device);
ibta.connect(Device);楼主 最后还是用到了IBluetoothA2dp这个,是如何定义的啊?
引用也引用不了啊!