I have a service that start a call when something happened, that works prefect but my question is how can I start it with speaker on?(and remove the speaker after 2 min?)
according to your all 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 the call from 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, It doesnt work.. why?