투케이2K

628. (Android/Java) [Android 13] 안드로이드 AudioManager 사용해 벨소리 볼륨 UP , DOWN 수행 - STREAM_RING 본문

Android

628. (Android/Java) [Android 13] 안드로이드 AudioManager 사용해 벨소리 볼륨 UP , DOWN 수행 - STREAM_RING

투케이2K 2023. 8. 24. 20:21

[개발 환경 설정]

개발 툴 : AndroidStudio

 

[소스 코드]

 

    // -----------------------------------------------------------------------------------------
    // TODO [SEARCH FAST] : [벨소리 볼륨 UP]
    // -----------------------------------------------------------------------------------------
    public static void setRingVolumeUP(Context mContext) {
        try {
            // ===============================================================
            S_Log._D_("벨소리 볼륨 UP 이벤트 지정", null);
            // ===============================================================

            AudioManager mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
            mAudioManager.adjustStreamVolume(AudioManager.STREAM_RING, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }





    // -----------------------------------------------------------------------------------------
    // TODO [SEARCH FAST] : [벨소리 볼륨 DOWN]
    // -----------------------------------------------------------------------------------------
    public static void setRingVolumeDOWN(Context mContext) {
        try {
            // ===============================================================
            S_Log._D_("벨소리 볼륨 DOWN 이벤트 지정", null);
            // ===============================================================

            AudioManager mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
            mAudioManager.adjustStreamVolume(AudioManager.STREAM_SYSTEM, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

 

반응형
Comments