Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Released under the Apache License, Version 2.0

import android.media.AudioManager;

public class Main {
    /**
     * Utility method that
     * @param am the AudioManager requesting the focus
     * @param afChangeListener the foucs listener associated to the AudioManager
     * @return true if focus is granted, false if not.
     */
    public static boolean focusRequestGranted(AudioManager am, Object afChangeListener) {
        int result = am.requestAudioFocus((AudioManager.OnAudioFocusChangeListener) afChangeListener,
                AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
        return result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
    }
}