android - Programmatically activate loudspeaker when receiving phone call -
hey..i plan add function app auto switch on loudspeaker when user received phone call..
here part of codes:
case telephonymanager.call_state_offhook: //call_state_offhook; setvolumecontrolstream(audiomanager.stream_voice_call); am.setmode(audiomanager.mode_in_call); am.setspeakerphoneon(true); boolean check = am.isspeakerphoneon(); toast.maketext(speaker.this, "loudspeaker on: "+ check,toast.length_long).show();
and added permission modify_audio_settings in manifest..however..the speakerphone didnt manage turn on..can kindly give helping hand on problem..thanks in advance..by way..this app implement in android 2.1
try hold 500 ms before turning on ..
so :
case telephonymanager.call_state_offhook: // call_state_offhook; try { thread.sleep(500); // delay 0,5 seconds handle better turning on // loudspeaker } catch (interruptedexception e) { } setvolumecontrolstream(audiomanager.stream_voice_call); am.setmode(audiomanager.mode_in_call); am.setspeakerphoneon(true); boolean check = am.isspeakerphoneon(); toast.maketext(speaker.this, "loudspeaker on: " + check, toast.length_long).show();
btw have xperia 4.1.2 , initial code working without issue ..
Comments
Post a Comment