audio 를 play할지 여부를 결정짓는 code
vibrate mode인 상태에도 이어폰이 있거나, 블투가 살아있으면 true를 return
refer to sayNotiText.apk
private boolean isHeadphonesPlugged(){
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
assert am != null;
AudioDeviceInfo[] audioDevices = am.getDevices(AudioManager.GET_DEVICES_ALL);
for(AudioDeviceInfo deviceInfo : audioDevices){
if(deviceInfo.getType()==AudioDeviceInfo.TYPE_WIRED_HEADPHONES
|| deviceInfo.getType()==AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
|| deviceInfo.getType()==AudioDeviceInfo.TYPE_BLUETOOTH_SCO
|| deviceInfo.getType()==AudioDeviceInfo.TYPE_WIRED_HEADSET){
return true;
}
}
return false;
}
'android source ' 카테고리의 다른 글
public directory 가져오기 (0) | 2019.07.23 |
---|---|
webView, file url link (0) | 2019.07.23 |
arrayList 를 SharedPreference에 save, get 하기 (0) | 2019.07.16 |
utils.readlines() (0) | 2019.07.16 |
utils. log(), append2file(), write2file() (0) | 2019.07.16 |