Search code examples
androidbroadcastreceiverringtone

Playing ringtons in a broadcast receiver


I use pending_intents and a broadcast_receiver for pending events processing. When the broadcast_receiver receives an intent it creates an instance of a ringtone with STREAM_NOTIFICATION and `play()' it. But sounds is late for a few dozen minutes!

I have checked that the pending_intens are come in proper time and the broadcast_receiver processes them properly.

It seems there is a problem with playing notifications while a phone stay in sleep mode (screen is off).

Somebody know how to bypass the problem?


Solution

  • It seems that the PowerManager and WakeLock classes should be used to enable processor unit.