AudioManager: update javadoc for setCommunicationDevice

Remove exception handling from example code for setCommunicationDevice.

Bug: 179709789
Test: make
Change-Id: I4f3285b128825ffba683ce32ffce4066878100b9
This commit is contained in:
Eric Laurent
2021-03-09 19:58:39 +01:00
parent c7f9fc813a
commit 9a40448628

View File

@@ -7087,26 +7087,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.