com.github.jvanhie.discogsscrobbler.util.NowPlayingAlarm.java Source code

Java tutorial

Introduction

Here is the source code for com.github.jvanhie.discogsscrobbler.util.NowPlayingAlarm.java

Source

/*
 * Copyright (c) 2014 Jono Vanhie-Van Gerwen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.jvanhie.discogsscrobbler.util;

import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;

/**
 * Created by Jono on 28/04/2014.
 */
public class NowPlayingAlarm extends WakefulBroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        //alarm was fired, call the now playing service with the right extras
        Intent i = new Intent(context, NowPlayingService.class);
        i.putExtra(NowPlayingService.NEXT_TRACK_MODE, true);
        i.putExtra(NowPlayingService.NEXT_TRACK_TITLE, intent.getStringExtra(NowPlayingService.NEXT_TRACK_TITLE));
        i.putExtra(NowPlayingService.NEXT_TRACK_ID, intent.getIntExtra(NowPlayingService.NEXT_TRACK_ID, 0));
        startWakefulService(context, i);
    }
}