本文整理汇总了Java中android.media.AudioDeviceInfo类的典型用法代码示例。如果您正苦于以下问题:Java AudioDeviceInfo类的具体用法?Java AudioDeviceInfo怎么用?Java AudioDeviceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioDeviceInfo类属于android.media包,在下文中一共展示了AudioDeviceInfo类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasWiredHeadset
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Checks whether a wired headset is connected or not.
* This is not a valid indication that audio playback is actually over
* the wired headset as audio routing depends on other conditions. We
* only use it as an early indicator (during initialization) of an attached
* wired headset.
*/
@Deprecated
private boolean hasWiredHeadset() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return audioManager.isWiredHeadsetOn();
} else {
final AudioDeviceInfo[] devices = audioManager.getDevices(android.media.AudioManager.GET_DEVICES_ALL);
for (AudioDeviceInfo device : devices) {
final int type = device.getType();
if (type == AudioDeviceInfo.TYPE_WIRED_HEADSET) {
Log.d(TAG, "hasWiredHeadset: found wired headset");
return true;
} else if (type == AudioDeviceInfo.TYPE_USB_DEVICE) {
Log.d(TAG, "hasWiredHeadset: found USB audio device");
return true;
}
}
return false;
}
}
开发者ID:nhancv,项目名称:nc-android-webrtcpeer,代码行数:27,代码来源:RTCAudioManager.java
示例2: hasWiredHeadset
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Checks whether a wired headset is connected or not.
* This is not a valid indication that audio playback is actually over
* the wired headset as audio routing depends on other conditions. We
* only use it as an early indicator (during initialization) of an attached
* wired headset.
*/
@Deprecated
private boolean hasWiredHeadset() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return audioManager.isWiredHeadsetOn();
} else {
final AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_ALL);
for (AudioDeviceInfo device : devices) {
final int type = device.getType();
if (type == AudioDeviceInfo.TYPE_WIRED_HEADSET) {
Log.d(TAG, "hasWiredHeadset: found wired headset");
return true;
} else if (type == AudioDeviceInfo.TYPE_USB_DEVICE) {
Log.d(TAG, "hasWiredHeadset: found USB audio device");
return true;
}
}
return false;
}
}
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:27,代码来源:AppRTCAudioManager.java
示例3: hasSpeacker
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Used to get if the device has a speacker
* @return
*/
public boolean hasSpeacker()
{
PackageManager packageManager = this.getPackageManager();
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
// Check whether the device has a speaker.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Check FEATURE_AUDIO_OUTPUT to guard against false positives.
if (!packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) {
return false;
}
AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
for (AudioDeviceInfo device : devices) {
if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
return true;
}
}
}
return false;
}
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:26,代码来源:MainActivity.java
示例4: hasWiredHeadset
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Checks whether a wired headset is connected or not.
* This is not a valid indication that audio playback is actually over
* the wired headset as audio routing depends on other conditions. We
* only use it as an early indicator (during initialization) of an attached
* wired headset.
*/
@Deprecated
private boolean hasWiredHeadset() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return audioManager.isWiredHeadsetOn();
} else {
final AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_ALL);
for (AudioDeviceInfo device : devices) {
final int type = device.getType();
if (type == AudioDeviceInfo.TYPE_WIRED_HEADSET) {
Log.d(TAG, "hasWiredHeadset: found wired headset");
return true;
} else if (type == AudioDeviceInfo.TYPE_USB_DEVICE) {
Log.d(TAG, "hasWiredHeadset: found USB audio device");
return true;
}
}
return false;
}
}
开发者ID:zxcpoiu,项目名称:react-native-incall-manager,代码行数:27,代码来源:InCallManagerModule.java
示例5: wearHasSpeaker
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Determines if the wear device has a built-in speaker or not.
* <p>
* <p><b>Important: </b>This method should only be called on a wear device; the return value on
* a non-wear device can be trusted if and only if the device is running android version M+.
*/
public static final boolean wearHasSpeaker(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PackageManager packageManager = context.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) context
.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;
}
}
}
return false;
}
开发者ID:csarron,项目名称:GmsWear,代码行数:27,代码来源:WearUtil.java
示例6: findAudioDevice
import android.media.AudioDeviceInfo; //导入依赖的package包/类
private AudioDeviceInfo findAudioDevice(int deviceFlag, int deviceType) {
AudioManager manager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adis = manager.getDevices(deviceFlag);
for (AudioDeviceInfo adi : adis) {
if (adi.getType() == deviceType) {
return adi;
}
}
return null;
}
开发者ID:googlecodelabs,项目名称:androidthings-googleassistant,代码行数:11,代码来源:AssistantActivity.java
示例7: setAudioInputDevice
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Sets a preferred {@link AudioDeviceInfo} device for input.
*
* @param device The preferred audio device to acquire audio from.
* @return Returns this builder to allow for chaining.
*/
public Builder setAudioInputDevice(AudioDeviceInfo device) {
mEmbeddedAssistant.mAudioInputDevice = device;
return this;
}
开发者ID:androidthings,项目名称:sample-googleassistant,代码行数:11,代码来源:EmbeddedAssistant.java
示例8: setAudioOutputDevice
import android.media.AudioDeviceInfo; //导入依赖的package包/类
/**
* Sets a preferred {@link AudioDeviceInfo} device for output.
*
* param device The preferred audio device to route audio to.
* @return Returns this builder to allow for chaining.
*/
public Builder setAudioOutputDevice(AudioDeviceInfo device) {
mEmbeddedAssistant.mAudioOutputDevice = device;
return this;
}
开发者ID:androidthings,项目名称:sample-googleassistant,代码行数:11,代码来源:EmbeddedAssistant.java
注:本文中的android.media.AudioDeviceInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论