마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

AudioAttributes()관련 에러입니다.

0 추천

mp3 파일을 alarm 형태로 울리기 위해서 코드 작성중 아래와 같은 에러가 나고 있습니다. 유경험자분 조언 부탁드립니다.

	private void initializeSoundPool(){
		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			AudioAttributes audioAttributes = new AudioAttributes().Builder()
					.setContentType(AudioAttributes.USAGE_ALARM)
					.setUsage(AudioAttributes.USAGE_ALARM)
					.build();

		}
	}

에러는 

"AudioAttributes() is not public in 'android.media.AudioAttributes cannot be accessed from outside package"

입니다. 어떻게 해결해야 될지 난감하네요..

 

 

 

 

 

익명사용자 님이 2016년 9월 6일 질문

1개의 답변

0 추천
 
채택된 답변
  1. builder 호출인데 () 로 호출하셨네요
    AudioAttributes.Builder()
  2. contentType 에는 해당 내용과 관련이 없습니다. 
/**
 * Content type value to use when the content type is unknown, or other than the ones defined.
 */
public final static int CONTENT_TYPE_UNKNOWN = 0;
/**
 * Content type value to use when the content type is speech.
 */
public final static int CONTENT_TYPE_SPEECH = 1;
/**
 * Content type value to use when the content type is music.
 */
public final static int CONTENT_TYPE_MUSIC = 2;
/**
 * Content type value to use when the content type is a soundtrack, typically accompanying
 * a movie or TV program.
 */
public final static int CONTENT_TYPE_MOVIE = 3;
/**
 * Content type value to use when the content type is a sound used to accompany a user
 * action, such as a beep or sound effect expressing a key click, or event, such as the
 * type of a sound for a bonus being received in a game. These sounds are mostly synthesized
 * or short Foley sounds.
 */
public final static int CONTENT_TYPE_SONIFICATION = 4;

결론

 

AudioAttributes aa = new AudioAttributes.Builder()
        .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
        .setUsage(AudioAttributes.USAGE_ALARM)
        .build();
aucd29 (218,390 포인트) 님이 2016년 9월 6일 답변
...