ProfileBasepublic final class A2dpSource extends Object implements ProfileBase
The static method getProfile(ohos.app.Context) is used to obtain A2dpSource instances.
You can use getDevicesByStates(int[]) to obtain devices in the specified state,
use getDeviceState(ohos.bluetooth.BluetoothRemoteDevice) to obtain the status of a peer device, and use
getPlayingState(ohos.bluetooth.BluetoothRemoteDevice) to obtain the A2dpSource playing status of a device.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
STATE_NOT_PLAYING |
Indicates that the A2DP source is not playing.
|
static int |
STATE_PLAYING |
Indicates that the A2DP source is playing.
|
A2DP, A2DP_SINK, CONNECT_STRATEGY_ALLOW, CONNECT_STRATEGY_AUTO, CONNECT_STRATEGY_DISALLOW, CONNECT_STRATEGY_UNKNOWN, GATT, GATT_SERVER, HFP, HFP_UNIT, MAP_SERVER, PBAP_CLIENT, PBAP_SERVER, PROFILE_PARAM_CUR_STATE, PROFILE_PARAM_PRE_STATE, SOCKET_MANAGER, STATE_CONNECTED, STATE_CONNECTING, STATE_DISCONNECTED, STATE_DISCONNECTING| 限定符和类型 | 方法 | 说明 |
|---|---|---|
List<BluetoothRemoteDevice> |
getDevicesByStates(int[] states) |
Obtains the list of devices in the specified status.
|
int |
getDeviceState(BluetoothRemoteDevice device) |
Obtains the connection status of a
BluetoothRemoteDevice in the current profile. |
int |
getPlayingState(BluetoothRemoteDevice device) |
Obtains the A2DP source playing status of a peer device.
|
static A2dpSource |
getProfile(Context context) |
Obtains the default
A2dpSource instance to perform an A2DP source operation. |
public static final int STATE_NOT_PLAYING
public static final int STATE_PLAYING
public static A2dpSource getProfile(Context context)
A2dpSource instance to perform an A2DP source operation.context - Indicates the Ability context that contains the package name.A2dpSource instance.public List<BluetoothRemoteDevice> getDevicesByStates(int[] states)
ProfileBasegetDevicesByStates 在接口中 ProfileBasestates - Indicates the connection status, which can be ProfileBase.STATE_DISCONNECTED,
ProfileBase.STATE_CONNECTING, ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.BluetoothRemoteDevice matching the specified status.public int getDeviceState(BluetoothRemoteDevice device)
ProfileBaseBluetoothRemoteDevice in the current profile.getDeviceState 在接口中 ProfileBasedevice - Indicates the BluetoothRemoteDevice.ProfileBase.STATE_DISCONNECTED, ProfileBase.STATE_CONNECTING,
ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.public int getPlayingState(BluetoothRemoteDevice device)
device - Indicates the peer device BluetoothRemoteDevice.STATE_PLAYING
or STATE_NOT_PLAYING.