On Mon, Oct 24, 2011 at 1:57 AM, John Goche <johngoch...@googlemail.com>wrote:
> > Well, here is what I am doing now: I acquire a wakelock inside the > broadcast receiver > and release it from my activity. The only problem I have is that the play() > method is > asynchronous. I would like to be notified when the sound stops playing via > a callback > but I see no method for doing so here: > > > http://developer.android.com/reference/android/media/Ringtone.html#play%28%29 > > I wonder whether there is a way to detect this without having to poll > calling isPlaying() > every second or so. > Well, here is the solution to turning off the wakelock when the sound stops playing: Regards, John Goche this.ringtone = RingtoneManager.getRingtone(this, uri); if (this.ringtone != null) this.ringtone.play(); // check every five minutes if ringtone is done // and release wake lock when done playing alarm sound final int checkInterval = 5000; final Runnable runnable = new Runnable() { public void run() { System.out.println("I'm running!!!"); System.out.println(!AlarmExpiredActivity.this.ringtone.isPlaying()); System.out.println("OK."); if (AlarmExpiredActivity.this.ringtone != null && !AlarmExpiredActivity.this.ringtone.isPlaying()) WakeLockManager.putWakeLock(); else AlarmExpiredActivity.this.view.postDelayed(this, checkInterval); } }; this.view.postDelayed(runnable, checkInterval); -- 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