Anonymous Anonymous - 3 years ago
712 0

No description



package com.example.josue.cardgame;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.IBinder;

 * Created by josue on 12/4/2017.

public class
BGMService extends Service {

    private static final String TAG = null;
    MediaPlayer player;

    // This method binds a service with an activity, so returning null
    // tells us that we don't want the music bound to any one activity
    // (we'll be using the music toggle in the main menu)
    public IBinder onBind(Intent i){
        return null;

    public void onCreate() {
        player = MediaPlayer.create(this, R.raw.bgm);
        player.setLooping(true); // Set looping

    // This suppress comment is the only thing keeping the method from being uncompilable
    // Remove when we can figure out what to return, Android Studio has some suggestions
    public int onStartCommand(Intent intent, int flags, int startId) {
        // This will start the player with the initialization of the game
        return START_STICKY;

    // I think this is unnecessary since we aren't binding anything
    public IBinder onUnBind(Intent arg0) {
        return null;

    // Called when the music toggle is set to "off"
    public void onDestroy() {
        // Release the resources the app is using for playing media

    // A consideration for when the RAM is too low to execute tasks efficiently,
    // will check later
    public void onLowMemory() {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download