[Android] 알람 볼륨 설정 - Android


# 알람 볼륨 얻어오기
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
 int maxVol = am.getStreamMaxVolume(AudioManager.STREAM_ALARM);
 int curVol   = am.getStreamVolume(AudioManager.STREAM_ALARM);

# 알람 볼륨 설정
am.setStreamVolume(AudioManager.STREAM_ALARM, sbVolume.getProgress(),
               AudioManager.FLAG_PLAY_SOUND);

# 알람 소리 재생
 mp= new MediaPlayer();
 Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
 if( alert == null ) {
           return
 }
 mp.setDataSource(alert.toString());
 mp.setAudioStreamType(AudioManager.STREAM_ALARM);
      
 mp.setLooping(true);
 mp.prepare();
 mp.start();


덧글

댓글 입력 영역


adsense_search

adsense_180x150


adsense(200x200)