get Instance of AudioManager - Android Media

Android examples for Media:Auto Player

Description

get Instance of AudioManager

Demo Code


//package com.java2s;
import android.content.Context;
import android.media.AudioManager;

public class Main {
    private static final Object mSingletonLock = new Object();
    private static AudioManager audioManager;

    private static AudioManager getInstance(Context context) {
        synchronized (mSingletonLock) {
            if (audioManager != null)
                return audioManager;
            if (context != null)
                audioManager = (AudioManager) context
                        .getSystemService(Context.AUDIO_SERVICE);
            return audioManager;
        }/*from  w ww.j a v a 2  s  .  co m*/
    }
}

Related Tutorials