I am writing an alarm (kinda) app, which registers a broadcast intent with AlarmManager with the RTC_WAKEUP flag, to go off at a specified time. Works...
When the broadcast is received, the receiver starts an activity that plays a ringtone with MediaPlayer using the STREAM_ALARM stream, and does some other stuff. All that works, but if the broadcast is received when the screen is off, the activity is starts up correctly but the ringtone does not play. Works fine and plays ringtone if received when the screen is on and unlocked. Are there any additional flags to set? Here's the code of the activity started from the Receiver. public void onCreate(Bundle bundle) { super.onCreate(bundle) ... Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); ringtonePlayer = new MediaPlayer(); ... playRingtone();} private void playRingtone() throws IllegalArgumentException, SecurityException, IllegalStateException, IOException { ringtonePlayer.setDataSource(prefs.getString(getRingTone(), RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE).toString())); ringtonePlayer.setAudioStreamType(AudioManager.STREAM_ALARM); ringtonePlayer.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK); ringtonePlayer.setLooping(true); ringtonePlayer.prepare(); ringtonePlayer.start(); Log.i(LOG_TAG, "Ringtone started");} -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.