Merge "AudioManager: update javadoc for setCommunicationDevice" into sc-dev am: 5bcb005a76

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13815794

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic90569abae897b919c4e9a51d9de335820c27f3d
This commit is contained in:
Eric Laurent
2021-03-11 17:15:57 +00:00
committed by Automerger Merge Worker

View File

@@ -7084,26 +7084,22 @@ public class AudioManager {
* <pre class="prettyprint">
* // Get an AudioManager instance
* AudioManager audioManager = Context.getSystemService(AudioManager.class);
* try {
* AudioDeviceInfo speakerDevice = null;
* List<AudioDeviceInfo> devices = audioManager.getAvailableCommunicationDevices();
* for (AudioDeviceInfo device : devices) {
* if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
* speakerDevice = device;
* break;
* }
* AudioDeviceInfo speakerDevice = null;
* List<AudioDeviceInfo> devices = audioManager.getAvailableCommunicationDevices();
* for (AudioDeviceInfo device : devices) {
* if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
* speakerDevice = device;
* break;
* }
* if (speakerDevice != null) {
* // Turn speakerphone ON.
* boolean result = audioManager.setCommunicationDevice(speakerDevice);
* if (!result) {
* // Handle error.
* }
* // Turn speakerphone OFF.
* audioManager.clearCommunicationDevice();
* }
* if (speakerDevice != null) {
* // Turn speakerphone ON.
* boolean result = audioManager.setCommunicationDevice(speakerDevice);
* if (!result) {
* // Handle error.
* }
* } catch (IllegalArgumentException e) {
* // Handle exception.
* // Turn speakerphone OFF.
* audioManager.clearCommunicationDevice();
* }
* </pre>
* @param device the requested audio device.