Created
December 27, 2019 11:10
-
-
Save Ochornma/cafe1af1eb941d7e7c182278ffdf4b78 to your computer and use it in GitHub Desktop.
Checking for speaker support on WearOS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PackageManager packageManager = getPackageManager(); | |
| // The results from AudioManager.getDevices can't be trusted unless the device | |
| // advertises FEATURE_AUDIO_OUTPUT. | |
| if (!packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) { | |
| return false; | |
| } | |
| AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); | |
| AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS); | |
| for (AudioDeviceInfo device : devices) { | |
| if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) { | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment