set All Sound - Android Phone

Android examples for Phone:Sound

Description

set All Sound

Demo Code


//package com.java2s;

import android.content.Context;

import android.media.AudioManager;

public class Main {

    public static void setAllSound(Context context, int systemsound,
            int callsound, int ringtonesound, int musicsound, int alarmsound) {
        AudioManager manager = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);
        try {/*from   www  . j ava 2 s . co m*/
            manager.setStreamVolume(AudioManager.STREAM_SYSTEM,
                    systemsound, 0);
            manager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
                    callsound, 0);
            manager.setStreamVolume(AudioManager.STREAM_RING,
                    ringtonesound, 0);
            manager.setStreamVolume(AudioManager.STREAM_MUSIC, musicsound,
                    0);
            manager.setStreamVolume(AudioManager.STREAM_ALARM, alarmsound,
                    0);
        } catch (Exception e) {
        }
    }
}

Related Tutorials