2012-12-08 2 views
1

안녕하세요. 맞춤 알람 소리를 설정하는 방법을 궁금합니다.android에서 맞춤 알람 소리 설정하기

이 내 코드입니다 : (: S) 그것은 notications/사운드를하지만 경보를 위해 노력하고 있습니다

RingtoneManager.setActualDefaultRingtoneUri(
        this, 
        RingtoneManager.TYPE_ALARM, 
        newUri 
        ); 

?

Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); 
    playRingtone(RingtoneManager.getRingtone(getApplicationContext(), ringtoneUri)); 

그리고, 벨소리를 재생을 다른 방법 playRingtone (벨소리 newRingtone를) 쓰기 : 사전에

감사

답변

1

당신이 시도 코드를

Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); 
if(alert == null){ 
    // alert is null, using backup 
    alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    if(alert == null){ // I can't see this ever being null (as always have a default notification) but just incase 
     // alert backup is null, using 2nd backup 
     alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);    
    } 
} 
+0

인터넷에서 해당 코드를 찾았지만 작동하지 않습니다. – David

+0

위의 경보 음 설정 방법은 작동하지만 음색을 사용하려면 새 경보를 만들어야합니다. – David

0

을 사용할 수 있습니다 .

private void playRingtone(Ringtone newRingtone) { 

     if(null != mCurrentRingtone && mCurrentRingtone.isPlaying()) 
      mCurrentRingtone.stop(); 

      mCurrentRingtone = newRingtone; 

     if(null != newRingtone){ 
      mCurrentRingtone.play(); 
     } 
    } 
관련 문제