AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); private void setSpeakerphoneOn(boolean on) { if(on) { audioManager.setSpeakerphoneOn(true); } else { audioManager.setSpeakerphoneOn(false);//关闭扬声器 audioManager.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL); setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); //把声音设定成Earpiece(听筒)出来,设定为正在通话中 audioManager.setMode(AudioManager.MODE_IN_CALL); } }
Android手机听筒和扬声器切换
最新推荐文章于 2024-09-27 10:29:04 发布