I have the following code. When the alarm is triggered, if I have a bluetooth device connected, it will play on through bluetooth.
I have found an app that when playing an alarm, it plays through both the bluetooth and speaker (although not in sync) at the same time with no special permissions. I'm wanting to do the same.
NOTE: I've tried setting STREAM_ALARM as well.
if (audioManager != null)
{
iOriginalVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mediaPlayer = MediaPlayer.create(this,
Uri.parse(AppInit.sPrefs.getString(AppInit.ALARM_URI, "")));
if (mediaPlayer == null)
{
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
mediaPlayer = MediaPlayer.create(this, uri);
}
mediaPlayer.setVolume(8f, 8f);
mediaPlayer.setLooping(true);
mediaPlayer.start();
}