java.lang.Object | |
↳ | android.bluetooth.BluetoothA2dp |
This class provides the public APIs to control the Bluetooth A2DP profile.
BluetoothA2dp is a proxy object for controlling the Bluetooth A2DP
Service via IPC. Use getProfileProxy(Context, BluetoothProfile.ServiceListener, int)
to get
the BluetoothA2dp proxy object.
Android only supports one connected Bluetooth A2dp device at a time. Each method is protected with its appropriate permission.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_CONNECTION_STATE_CHANGED | Intent used to broadcast the change in connection state of the A2DP profile. | |||||||||
String | ACTION_PLAYING_STATE_CHANGED | Intent used to broadcast the change in the Playing state of the A2DP profile. | |||||||||
int | STATE_NOT_PLAYING | A2DP sink device is NOT streaming music. | |||||||||
int | STATE_PLAYING | A2DP sink device is streaming music. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.bluetooth.BluetoothProfile
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Invoked when the garbage collector has detected that this instance is no longer reachable.
| |||||||||||
Get connected devices for this specific profile.
| |||||||||||
Get the current connection state of the profile
Requires | |||||||||||
Get a list of devices that match any of the given connection
states.
| |||||||||||
Check if A2DP profile is streaming music.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.bluetooth.BluetoothProfile
|
Intent used to broadcast the change in connection state of the A2DP profile.
This intent will have 3 extras:
EXTRA_STATE
- The current state of the profile. EXTRA_PREVIOUS_STATE
- The previous state of the profile.EXTRA_DEVICE
- The remote device. EXTRA_STATE
or EXTRA_PREVIOUS_STATE
can be any of
STATE_DISCONNECTED
, STATE_CONNECTING
,
STATE_CONNECTED
, STATE_DISCONNECTING
.
Requires BLUETOOTH
permission to
receive.
Intent used to broadcast the change in the Playing state of the A2DP profile.
This intent will have 3 extras:
EXTRA_STATE
- The current state of the profile. EXTRA_PREVIOUS_STATE
- The previous state of the profile. EXTRA_DEVICE
- The remote device. EXTRA_STATE
or EXTRA_PREVIOUS_STATE
can be any of
STATE_PLAYING
, STATE_NOT_PLAYING
,
Requires BLUETOOTH
permission to
receive.
A2DP sink device is NOT streaming music. This state can be one of
EXTRA_STATE
or EXTRA_PREVIOUS_STATE
of
ACTION_PLAYING_STATE_CHANGED
intent.
A2DP sink device is streaming music. This state can be one of
EXTRA_STATE
or EXTRA_PREVIOUS_STATE
of
ACTION_PLAYING_STATE_CHANGED
intent.
Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.
Note that objects that override finalize
are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit close
method (and implement
Closeable
), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a BigInteger
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
If you must use finalizers, consider at least providing your own
ReferenceQueue
and having your own thread process that queue.
Unlike constructors, finalizers are not automatically chained. You are responsible for
calling super.finalize()
yourself.
Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
Get connected devices for this specific profile.
Return the set of devices which are in state STATE_CONNECTED
Requires BLUETOOTH
permission.
Get the current connection state of the profile
Requires BLUETOOTH
permission.
device | Remote bluetooth device. |
---|
STATE_CONNECTED
, STATE_CONNECTING
,
STATE_DISCONNECTED
, STATE_DISCONNECTING
Get a list of devices that match any of the given connection states.
If none of the devices match any of the given states, an empty list will be returned.
Requires BLUETOOTH
permission.
states | Array of states. States can be one of
STATE_CONNECTED , STATE_CONNECTING ,
STATE_DISCONNECTED , STATE_DISCONNECTING , |
---|
Check if A2DP profile is streaming music.
Requires BLUETOOTH
permission.
device | BluetoothDevice device |
---|