이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Manage calls using the Telecom API\n\nThis guide covers how to route audio for Bluetooth devices using the\n[Telecom API](/develop/connectivity/telecom) and set the connection for\nVoIP calls. Read the\n[Build a calling app](/develop/connectivity/telecom/selfManaged) guide\nbefore continuing.\n\nBy using the [`ConnectionService`](/reference/android/telecom/ConnectionService)\nand [`Connection`](/reference/android/telecom/Connection) classes, you can access\nthe audio state and a list of available Bluetooth devices, and can route\naudio to a selected Bluetooth device.\n\nVoIP Connection and ConnectionService\n-------------------------------------\n\nCreate a `VoIPConnection` class that extends from\n[`Connection`](/reference/android/telecom/Connection). This class controls the state of the current call. As the\n[Build a calling app](/develop/connectivity/telecom/selfManaged) guide\nstates, make this a self-managed application and set the audio mode for a VoIP\napplication. \n\n### Kotlin\n\n```kotlin\nclass VoIPConnection : Connection() {\n init {\n setConnectionProperties(PROPERTY_SELF_MANAGED)\n setAudioModeIsVoip(true)\n }\n}\n```\n\n### Java\n\n```java\npublic class VoIPConnection extends Connection {\n public VoIPConnection() {\n setConnectionProperties(PROPERTY_SELF_MANAGED);\n setAudioModeIsVoip(true);\n }\n}\n```\n\nNext, return an instance of this class in\n[`ConnectionService`](/reference/android/telecom/ConnectionService) when an\nincoming or outgoing call occurs. \n\n### Kotlin\n\n```kotlin\nclass VoIPConnectionService : ConnectionService() {\n override fun onCreateOutgoingConnection(\n connectionManagerPhoneAccount: PhoneAccountHandle,\n request: ConnectionRequest,\n ): Connection {\n return VoIPConnection()\n }\n}\n```\n\n### Java\n\n```java\npublic class VoIPConnectionService extends ConnectionService {\n @Override\n public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {\n return new VoIPConnection();\n }\n}\n```\n\nEnsure the manifest correctly points to the `VoIPConnectionService` class. \n\n \u003cservice android:name=\".voip.TelegramConnectionService\" android:permission=\"android.permission.BIND_TELECOM_CONNECTION_SERVICE\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.telecom.ConnectionService\"/\u003e\n \u003c/intent-filter\u003e\n \u003c/service\u003e\n\nWith these custom [`Connection`](/reference/android/telecom/Connection) and\n[`ConnectionService`](/reference/android/telecom/ConnectionService) classes, you\ncan control which device and what type of audio routing you wish to use during a\ncall.\n\nGet the current audio state\n---------------------------\n\nTo get the current audio state, call\n[`getCallAudioState()`](/reference/android/telecom/Connection#getCallAudioState()).\n[`getCallAudioState()`](/reference/android/telecom/Connection#getCallAudioState())\nreturns if the device is streaming using Bluetooth, Earpiece, Wired, or\nSpeaker. \n\n mAudioState = connection.getCallAudioState()\n\nOn State Changed\n----------------\n\nSubscribe to changes in CallAudioState by overriding\n[`onCallAudioStateChanged()`](/reference/android/telecom/Connection#onCallAudioStateChanged(android.telecom.CallAudioState)).\nThis alerts you of any changes to the state. \n\n### Kotlin\n\n```kotlin\nfun onCallAudioStateChanged(audioState: CallAudioState) {\n mAudioState = audioState\n}\n```\n\n### Java\n\n```java\n@Override\npublic void onCallAudioStateChanged(CallAudioState audioState) {\n mAudioState = audioState;\n}\n```\n\nGet the current device\n----------------------\n\nGet the current active device using\n[`CallAudioState.getActiveBluetoothDevice()`](/reference/android/telecom/CallAudioState#getActiveBluetoothDevice()).\nThis function returns the active Bluetooth device.\n**Note:** This feature is only available in API level 28 and higher. \n\n### Kotlin\n\n```kotlin\nval activeDevice: BluetoothDevice = mAudioState.getActiveBluetoothDevice()\n```\n\n### Java\n\n```java\nBluetoothDevice activeDevice = mAudioState.getActiveBluetoothDevice();\n```\n\nGet Bluetooth devices\n---------------------\n\nGet a list of Bluetooth devices that are available for call audio routing using\n[`CallAudioState.getSupportedBluetoothDevices()`](/reference/android/telecom/CallAudioState#getSupportedBluetoothDevices()). \n\n### Kotlin\n\n```kotlin\nval availableBluetoothDevices: Collection =\n mAudioState.getSupportedBluetoothDevices()\n```\n\n### Java\n\n```java\nCollection availableBluetoothDevices = mAudioState.getSupportedBluetoothDevices();\n```\n\nRoute the call audio\n--------------------\n\n### Using API level 28 and higher (recommended)\n\nRoute the call audio to an available Bluetooth device using\n[`requestBluetoothAudio(BluetoothDevice)`](/reference/android/telecom/Connection#requestBluetoothAudio(android.bluetooth.BluetoothDevice)): \n\n requestBluetoothAudio(availableBluetoothDevices[0]);\n\n### Using API level 23 and higher\n\nEnable\n[`ROUTE_BLUETOOTH`](/reference/android/telecom/CallAudioState#ROUTE_BLUETOOTH)\nwithout specifying the device using\n[`setAudioRoute(int)`](/reference/android/telecom/Connection#setAudioRoute(int)).\nThis defaults routing to current, active bluetooth devices on Android 9 and higher. \n\n setAudioRoute(CallAudioState.ROUTE_BLUETOOTH);\n\n| **Note:** This step isn't required if the app already knows which Bluetooth device to route audio to."]]