本文整理匯總了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;
}