Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2014 Fastboot Mobile, LLC.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, see <http://www.gnu.org/licenses>.
 */

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

public class Main {
    private static final String AVRCP_PLAYSTATE_CHANGED = "com.android.music.playstatechanged";
    private static final String KEY_PLAYING = "playing";
    private static final String KEY_POSITION = "position";

    public static void notifyPlayStateChanged(Context ctx, boolean playing, long position) {
        // The bluetooth stuff assumes STOP if playing == false && position = 0, PAUSE if
        // playing == false && position > 0, and PLAYING if playing == true
        Intent i = new Intent(AVRCP_PLAYSTATE_CHANGED);
        i.putExtra(KEY_PLAYING, playing);
        i.putExtra(KEY_POSITION, position);

        ctx.sendBroadcast(i);
    }
}