android - Start call with speaker via intent -
i have service start call when happened, works prefect question how can start speaker on?(and remove speaker after 2 min?)
according anwsers,
this code should work -
intent intent = new intent(intent.action_call); intent.setdata(uri.parse("tel:" + num)); intent.addflags(intent.flag_activity_new_task); intent.addflags(intent.flag_from_background);// (i'm starting call service..) startactivity(intent); //the call start here, work perfect audiomanager audiomanager = (audiomanager) getsystemservice(context.audio_service); audiomanager.setmode(audiomanager.mode_in_call); audiomanager.setspeakerphoneon(true);
well, doesnt work.. why?
audiomanager audiomanager = (audiomanager) getsystemservice(context.audio_service); audiomanager.setmode(audiomanager.mode_in_call); audiomanager.setspeakerphoneon(true);
use turn speaker on once call picked up.
premission
<uses-permission android:name="android.permission.modify_audio_settings" />
register phonestatelistener
know when call picked up. urn speaker on when call state telephonymanager.call_state_offhook
audiomanager audiomanager = (audiomanager) getsystemservice(context.audio_service); audiomanager.setspeakerphoneon(false); audiomanager.setmode(audiomanager.mode_normal);
Comments
Post a Comment