Example usage for android.content Context AUDIO_SERVICE

List of usage examples for android.content Context AUDIO_SERVICE

Introduction

In this page you can find the example usage for android.content Context AUDIO_SERVICE.

Prototype

String AUDIO_SERVICE

To view the source code for android.content Context AUDIO_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.media.AudioManager for handling management of volume, ringer modes and audio routing.

Usage

From source file:Main.java

public static void playKeyPress(Context c) {
    AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE);
    am.playSoundEffect(AudioManager.FX_KEY_CLICK, (float) 0.25);
}

From source file:Main.java

public static boolean isOnPause(Context ctx) {
    AudioManager am = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    return am.getMode() != AudioManager.MODE_NORMAL;
}

From source file:Main.java

public static int getMaxVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static int getCurVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamVolume(AudioManager.STREAM_MUSIC);
}

From source file:Main.java

public static void setVolumeMute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

From source file:Main.java

public static int getRingVolume(Context context) {
    return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE))
            .getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

public static void setVolumeUnmute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, false);
}

From source file:Main.java

public static void setCurVolume(Context context, int index) {
    ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC,
            index, 0);/*from w w w.  j  a v a 2  s . com*/
}

From source file:Main.java

public static final int audioVolume(Context ctx) {
    AudioManager audio = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    return audio.getStreamVolume(AudioManager.STREAM_RING);
}

From source file:Main.java

public static int getRingerMode(Context mContext) {
    AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    return am.getRingerMode();
}