本文整理汇总了Java中android.bluetooth.BluetoothProfile.A2DP属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothProfile.A2DP属性的具体用法?Java BluetoothProfile.A2DP怎么用?Java BluetoothProfile.A2DP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.bluetooth.BluetoothProfile
的用法示例。
在下文中一共展示了BluetoothProfile.A2DP属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServiceDisconnected
@Override
public void onServiceDisconnected(int profile) {
Log.e("blueHeadsetListener", "onServiceDisconnected:" + profile);
if (profile == BluetoothProfile.A2DP) {
voiceMediator.setBluetoothA2dp(null);
} else if (profile == BluetoothProfile.HEADSET) {
voiceMediator.setBluetoothHeadset(null);
}
}
示例2: onServiceConnected
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
Log.e("blueHeadsetListener", "onServiceConnected:" + profile);
if (profile == BluetoothProfile.A2DP) {
voiceMediator.setBluetoothA2dp((BluetoothA2dp) proxy);
} else if (profile == BluetoothProfile.HEADSET) {
voiceMediator.setBluetoothHeadset((BluetoothHeadset) proxy);
}
}
示例3: onServiceConnected
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
try {
if (profile == BluetoothProfile.HEADSET) {
// bh = (BluetoothHeadset) proxy;
// if (bh.getConnectionState(mTouchObject.bluetoothDevice) != BluetoothProfile.STATE_CONNECTED){
// bh.getClass()
// .getMethod("connect", BluetoothDevice.class)
// .invoke(bh, mTouchObject.bluetoothDevice);
// }
} else if (profile == BluetoothProfile.A2DP) {
/**使用A2DP的协议连接蓝牙设备(使用了反射技术调用连接的方法)*/
a2dp = (BluetoothA2dp) proxy;
if (a2dp.getConnectionState(currentBluetoothDevice) != BluetoothProfile.STATE_CONNECTED) {
a2dp.getClass()
.getMethod("connect", BluetoothDevice.class)
.invoke(a2dp, currentBluetoothDevice);
Toast.makeText(MainActivity.this,"请播放音乐",Toast.LENGTH_SHORT).show();
getBondedDevices();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getProfileCode
@Override
public int getProfileCode() {
return BluetoothProfile.A2DP;
}