adapter.getProfileProxy(context, mProfileListener, BluetoothProfile.HEADSET);
private BluetoothProfile.ServiceListener mProfileListener =
new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = (BluetoothHeadset) proxy;
}
}
public void onServiceDisconnected(int profile) {
if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = null;
}
}
};
Use mBluetoothHeadset to call the functions on BluetoothHeadset.java
Note: Audio Connection is different from Connection.
> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>
Hi Hos and JaiKumar,
I have some errors when built the project-mProfileListener cannot be resolved to a variable
at line
mBluetoothAdapter.getProfileProxy(context, mProfileListener, BluetoothProfile.
HEADSET);
at line
private BluetoothProfile.ServiceListener mProfileListener = new BluetoothProfile.ServiceListener() {
-Cannot refer to a non-final variable mBluetoothHeadset inside an inner class defined in a different method
at line
mBluetoothHeadset
= (BluetoothHeadset) proxy;
and line
mBluetoothHeadset
=
null;
Can you tell me how to correct?
Thank you so much!