Android Open Source - sleep-timer Pause Music Receiver

From Project

Back to project page sleep-timer.


The source code is released under:

MIT License

If you think the Android project sleep-timer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

Copyright (c) 2013 Joel Andrews/*  ww w . j a va 2  s.c om*/
Distributed under the MIT License:

package com.oldsneerjaw.sleeptimer;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

 * Handles broadcast events intended to pause music playback indefinitely.
 * @author Joel Andrews
public class PauseMusicReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        pauseMusic(context, TimerManager.get(context), CountdownNotifier.get(context));

     * Pauses all music playback on the device.
     * @param context The context in which the receiver is running
     * @param timerManager The pause music timer manager
     * @param countdownNotifier The countdown notifier
    void pauseMusic(Context context, TimerManager timerManager, CountdownNotifier countdownNotifier) {

        // The service will be responsible for actually pausing playback and ensuring it remains paused until explicitly
        // restarted
        Intent serviceIntent = new Intent(context, PauseMusicService.class);
        context.startService(new Intent(context, PauseMusicService.class));

Java Source Code List